summaryrefslogtreecommitdiff
path: root/test/ruby/test_econv.rb
AgeCommit message (Collapse)Author
2021-04-26Fix some typos by spell checkerRyuta Kamizono
Notes: Merged: https://github.com/ruby/ruby/pull/4414
2020-07-10Encode ' as ' when using encode(xml: :attr)Jeremy Evans
Fixes [Bug #16922] Notes: Merged: https://github.com/ruby/ruby/pull/3177
2020-01-11Warn when :newline precedes other newline optionsNobuyoshi Nakada
2020-01-11Added assertions for newline decoratorsNobuyoshi Nakada
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2015-12-17transcode.c: infectionnobu
* transcode.c (rb_econv_substr_append, econv_primitive_convert): the result should be infected by the original string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* bootstraptest/runner.rb: use safe navigation operator.hsbt
[fix GH-1142] Patch by @mlarraz * test/openssl/test_pair.rb: ditto. * test/ruby/test_econv.rb: ditto. * test/ruby/test_settracefunc.rb: ditto. * test/thread/test_queue.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14test: use String#b instead of dup.force_encodingnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-03transcode.c: use stringnobu
* transcode.c (econv_opts): get rid of inadvertent ID creation, and preserve argument encoding in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13test/ruby: better assertionsnobu
* test/ruby: use better assertions instead of mere assert. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-05test_econv.rb: assert_separatelynobu
* test/ruby/test_econv.rb (test_default_external): use assert_separately for clearer messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25Suppress warnings.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-10* test/ruby/test_econv.rb (TestEncodingConverter#test_default_external): ↵nobu
drop stderr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-09* test/ruby/test_econv.rb (test_default_external): include iso-8859-16.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-09It should be require_relative.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-09* file.c (file_path_convert): don't convert it when the path string isnaruse
ascii only. [ruby-core:41556] [Bug #5733] tests are contributed by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-06* transcode.c: enabled econv newline option.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-26* io.c (validate_enc_binmode, rb_io_extract_modeenc): set newlinenobu
decorator according to open mode. * transcode.c (rb_econv_prepare_options): new function, to prepare econv options with newline flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-12* enc/trans/utf8_mac.trans (buf_apply): fix for patternsnaruse
whose result is 2 bytes. [ruby-core:30751] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-14avoid method redefinition.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-22* enc/trans/newline.trans (fun_so_universal_newline): generate \nakr
after \r\n detection instead of just after \r. [ruby-list:45988] [ruby-core:25881] [ruby-core:26788] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-26* enc/trans/utf8_mac.trans: Add converter for UTF8-MAC.naruse
* enc/trans/utf8_mac-tbl.rb: ditto. * test/ruby/test_econv.rb: tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06* {ext,lib,test}/**/*.rb: removed trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-25* transcode.c (rb_eUndefinedConversionError): renamed fromakr
rb_eConversionUndefinedError. (rb_eConverterNotFoundError): renamed from rb_eNoConverterError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-18* transcode.c: add "Error" suffix for Encoding exception classes.matz
a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp> in [ruby-dev:36346]. * encoding.c (Init_Encoding): rename EncodingCompatibilityError to Encoding::CompatibilityError. [ruby-dev:36366] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-12* transcode.c (rb_econv_prepare_opts): raise ArgumentError ifakr
a broken string is specified as a replacement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-12* enc/trans/escape.trans: transcoder name renamed to use underscore.akr
* transcode.c: follow the renaming. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-12* transcode.c (rb_econv_init_by_convpath_i): new function.akr
(rb_econv_init_by_convpath): new function. (econv_init): use rb_econv_init_by_convpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-12* transcode.c (decorator_names): extracted from rb_econv_open.akr
(rb_econv_open): use decorator_names. (econv_args): extracted from econv_init. (econv_init): use econv_args. (decorate_convpath): new function. (search_convpath_i): new function. (econv_s_search_convpath): new method. (Init_transcode): new method defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-10* transcode.c (make_encoding): new function.akr
(make_encobj): new function. (econv_s_asciicompat_encoding): use make_encoding. (rb_econv_open_exc): use SUPPLEMENTAL_CONVERSION. (econv_convpath): use encoding object in the result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-10* transcode.c (econv_convpath): new method.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-09* include/ruby/encoding.h (econv_after_output): renamed fromakr
econv_output_followed_by_input. (ECONV_AFTER_OUTPUT): renamed from ECONV_OUTPUT_FOLLOWED_BY_INPUT. * transcode.c: follow the renaming. * io.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-09* include/ruby/encoding.h (ECONV_DECORATOR_MASK): mergeakr
ECONV_ENCODER_MASK and ECONV_DECORATOR_MASK. (ECONV_UNIVERSAL_NEWLINE_DECORATOR): renamed from ECONV_UNIVERSAL_NEWLINE_DECODER. (ECONV_CRLF_NEWLINE_DECORATOR): renamed from ECONV_CRLF_NEWLINE_ENCODER. (ECONV_CR_NEWLINE_DECORATOR): renamed from ECONV_CR_NEWLINE_ENCODER. (ECONV_XML_TEXT_DECORATOR): renamed from ECONV_XML_TEXT_ENCODER. (ECONV_XML_ATTR_CONTENT_DECORATOR): renamed from ECONV_XML_ATTR_CONTENT_ENCODER. (ECONV_STATEFUL_DECORATOR_MASK): renamed from ECONV_STATEFUL_ENCODER_MASK. (ECONV_XML_ATTR_QUOTE_DECORATOR): renamed from ECONV_XML_ATTR_CONTENT_DECORATOR. * io.c: follow the renaming. * transcode.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-08* include/ruby/encoding.h (rb_econv_decorate_at_first): declared.akr
(rb_econv_decorate_at_last): declared. * transcode.c (rb_econv_open_by_transcoder_entries): initialize replacement_enc. allocate outbuf for the last transcoder. (rb_econv_open0): extracted from rb_econv_open. (rb_econv_open): use rb_econv_open0 and decorate the result using rb_econv_decorate_at_first and rb_econv_decorate_at_last. (rb_econv_decorate_at): new function. (rb_econv_decorate_at_first): ditto. (rb_econv_decorate_at_last): ditto. (rb_econv_binmode): fix iteration end condition. (econv_init): don't set source_encoding_name and destination_encoding_name because they are set in rb_econv_open0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-08* include/ruby/encoding.h (rb_econv_asciicompat_encoding): renamedakr
from rb_econv_stateless_encoding to apply stateless ASCII incompatible encodings such as UTF-16BE. * io.c (make_writeconv): use rb_econv_asciicompat_encoding. * transcode_data.h (rb_transcoder_asciicompat_type_t): renamed from rb_transcoder_stateful_type_t. (rb_transcoder): use rb_transcoder_asciicompat_type_t. * transcode.c: follow the type change. (asciicompat_encoding_i): renamed from stateless_encoding_i. (rb_econv_asciicompat_encoding): renamed from rb_econv_stateless_encoding. (econv_s_asciicompat_encoding): method renamed. * tool/transcode-tblgen.rb: follow the type change. * enc/trans/utf_16_32.trans: follow the type change. rb_from_UTF_16BE to UTF-8 is asciicompat_decoder. rb_from_UTF_16LE to UTF-8 is asciicompat_decoder. rb_from_UTF_32BE to UTF-8 is asciicompat_decoder. rb_from_UTF_32LE to UTF-8 is asciicompat_decoder. UTF-8 to rb_to_UTF_16BE is asciicompat_encoder. UTF-8 to rb_to_UTF_16LE is asciicompat_encoder. UTF-8 to rb_to_UTF_32BE is asciicompat_encoder. UTF-8 to rb_to_UTF_32LE is asciicompat_encoder. * enc/trans/newline.trans: follow the type change. universal newline decoder is asciicompat_converter. * enc/trans/escape.trans: follow the type change. * enc/trans/iso2022.trans: ditto. * enc/trans/japanese.trans: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-08* transcode.c (rb_econv_insert_output): "readagain" part should beakr
after replacement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-07* enc/trans/iso2022.trans: stateless-iso-2022-jp is defined to avoidakr
undefined conversion error between iso-2022-jp and the corresponding stateless encoding. * enc/emacs_mule.c: replicate emacs-mule as stateless-iso-2022-jp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-07* include/ruby/encoding.h (ECONV_XML_ATTR_CONTENT_ENCODER): defined.akr
(ECONV_STATEFUL_ENCODER_MASK): defined. (ECONV_XML_ATTR_QUOTE_ENCODER): defined. (ECONV_XML_ATTR_ENCODER): removed. * enc/trans/escape.trans (rb_escape_xml_attr_content): defined. (rb_escape_xml_attr_quote): defined. (rb_escape_xml_attr): removed. * io.c (NEED_WRITECONV): writeconv is required if supplemental converter is used. (make_writeconv): apply stateful encoder in writeconv. * transcode.c: follow the constant change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* include/ruby/encoding.h (ECONV_XML_TEXT_ENCODER): renamed fromakr
ECONV_HTML_TEXT_ENCODER. (ECONV_XML_ATTR_ENCODER): renamed from ECONV_HTML_ATTR_ENCODER. * enc/trans/escape.trans: follow the renaming. * transcode.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* transcode.c (str_transcode0): check ECONV_HTML_TEXT_ENCODER andakr
ECONV_HTML_ATTR_ENCODER. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* transcode.c (sym_html): new variable.akr
(sym_text): ditto. (sym_attr): ditto. (econv_opts): check :html=>:text and :html=>:attr. (Init_transcode): initialize the above variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* include/ruby/encoding.h (ECONV_HTML_TEXT_ENCODER): new constant.akr
(ECONV_HTML_ATTR_ENCODER): ditto. * transcode.c (rb_econv_open): check ECONV_HTML_TEXT_ENCODER and ECONV_HTML_ATTR_ENCODER. (Init_transcode): Encoding::Converter::HTML_TEXT_ENCODER and Encoding::Converter::HTML_ATTR_ENCODER defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* transcode.c (stateless_encoding_i): ignore supplemental conversions.akr
Encoding::Converter.stateless_encoding("html-attr-escaped") should be nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06* enc/trans/escape.trans (escape_html_attr_init): new function.akr
(fun_so_escape_html_attr): new function. (escape_html_attr_finish): new function. (rb_escape_html_attr): use them to quote the converted result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05add a test.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05* transcode.c (rb_econv_open): fail for ASCII incompatible withakr
newline conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05* enc/trans/escape.trans: new file.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e