aboutsummaryrefslogtreecommitdiffstats
path: root/transcode.c
Commit message (Collapse)AuthorAgeFilesLines
* Free everything at shutdownAdam Hess2023-12-071-0/+22
| | | | | | | when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Peter Zhu <peter@peterzhu.ca>
* Adjust indent [ci skip]Nobuyoshi Nakada2023-10-271-1/+1
|
* Don't check for null pointer in calls to freePeter Zhu2023-06-301-2/+1
| | | | | | | | According to the C99 specification section 7.20.3.2 paragraph 2: > If ptr is a null pointer, no action occurs. So we do not need to check that the pointer is a null pointer.
* [Feature #19579] Remove !USE_RVARGC code (#7655)Peter Zhu2023-04-041-4/+1
| | | | | | | | | | | Remove !USE_RVARGC code [Feature #19579] The Variable Width Allocation feature was turned on by default in Ruby 3.2. Since then, we haven't received bug reports or backports to the non-Variable Width Allocation code paths, so we assume that nobody is using it. We also don't plan on maintaining the non-Variable Width Allocation code, so we are going to remove it.
* [DOC] Use RDoc inclusions in transcode.cNobuyoshi Nakada2023-01-161-0/+9
|
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-1/+1
|
* Using is_broken_string functionS-H-GAMELINKS2022-09-101-1/+1
|
* Support Encoding::Converter newline: :lf and :lf_newline optionsJeremy Evans2022-08-191-1/+29
| | | | | | | | | | | | | | | | Previously, newline: :lf was accepted but ignored. Where it should have been used was commented out code that didn't work, but unlike all other invalid values, using newline: :lf did not raise an error. This adds support for newline: :lf and :lf_newline, for consistency with newline: :cr and :cr_newline. This is basically the same as universal_newline, except that it only affects writing and not reading due to RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK. Add tests for the File.open :newline option while here. Fixes [Bug #12436]
* [Bug #18964] Update the code range of appended portionNobuyoshi Nakada2022-08-181-4/+30
|
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-256/+256
| | | | [Misc #18891]
* Using is_ascii_string to check encodingS-H-GAMELINKS2022-06-171-1/+1
|
* [DOC] Place a non-US-ASCII document in a document-specific scriptNobuyoshi Nakada2022-02-261-48/+0
|
* [DOC] Enhanced RDoc for some encoding methods (#5598)Burdette Lamar2022-02-251-57/+44
| | | | | | | | | | | | | | In String, treats: #b #scrub #scrub! #unicode_normalize #unicode_normalize! #encode #encode! Also adds a note to IO.new (suggested by @jeremyevans).
* Add `econv_get_encoding` functionS.H2022-02-021-6/+10
|
* [Feature #18239] Implement VWA for stringsPeter Zhu2021-10-251-0/+4
| | | | | This commit adds support for embedded strings with variable capacity and uses Variable Width Allocation to allocate strings.
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-2/+2
|
* Make encoding loading not issue warningJeremy Evans2021-10-021-1/+3
| | | | | | | | | | | | | Instead of relying on setting an unsetting ruby_verbose, which is not thread-safe, restructure require_internal and load_lock to accept a warn argument for whether to warn, and add rb_require_internal_silent to require without warnings. Use rb_require_internal_silent when loading encoding. Note this does not modify ruby_debug and errinfo handling, those remain thread-unsafe. Also silent requires when loading transcoders.
* Using SYMBOL_P macroS-H-GAMELINKS2021-09-111-1/+1
|
* Replace RBOOL macroS-H-GAMELINKS2021-09-051-1/+1
|
* Extracted repeatedly defined IDsNobuyoshi Nakada2021-07-271-16/+34
|
* Don't redefine #rb_intern over and over againNobuyoshi Nakada2021-07-271-25/+24
|
* Work around issue transcoding issue with non-ASCII compatible encodings and ↵Jeremy Evans2021-06-261-0/+6
| | | | | | | | | | | | | | | | | | | | xml escaping When using a non-ASCII compatible source and destination encoding and xml escaping (the :xml option to String#encode), the resulting string was broken, as it used the correct non-ASCII compatible encoding, but contained data that was ASCII-compatible instead of compatible with the string's encoding. Work around this issue by detecting the case where both the source and destination encoding are non-ASCII compatible, and transcoding the source string from the non-ASCII compatible encoding to UTF-8. The xml escaping code will correctly handle the UTF-8 source string and the return the correctly encoded and escaped value. Fixes [Bug #12052] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
* Fix some typos by spell checkerRyuta Kamizono2021-04-261-1/+1
|
* fix result of example [ci skip]Nobuhiro IMAI2021-01-061-1/+1
|
* Data: delete卜部昌平2020-12-221-1/+1
| | | | | | | | Has been deprecated since 684bdf6171b76f5bc5e4f05926a5ab01ec2b4fd5. Matz says in [ruby-core:83954] that Data should be an alias of Object. Because rb_cData has not been deprecated, let us deprecate the constant to make it a C-level synonym of rb_cObject.
* Update documentation for String#encode{,!} [ci skip]Jeremy Evans2020-12-031-8/+8
| | | | | | | | These methods take keywords, not a hash. From tjschuck (T.J. Schuck) Fixes [Bug #17364]
* RARRAY_AREF: convert into an inline function卜部昌平2020-08-151-0/+1
| | | | | | RARRAY_AREF has been a macro for reasons. We might not be able to change that for public APIs, but why not relax the situation internally to make it an inline function.
* make_econv_exception: do not goto into a branch卜部昌平2020-06-291-12/+12
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* Fixed symbol misused as IDNobuyoshi Nakada2020-02-241-4/+4
| | | | | `rb_funcallv_public` and `rb_respond_to` require an `ID`, not a `Symbol`. [Bug #16649]
* more on NULL versus functions.卜部昌平2020-02-071-1/+1
| | | | | | Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
* Warn when :newline precedes other newline optionsNobuyoshi Nakada2020-01-111-3/+10
|
* decouple internal.h headers卜部昌平2019-12-261-2/+10
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-3/+0
| | | | | | 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.
* Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans2019-11-181-1/+1
| | | | | | | | | | | | | | | | | This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd.
* transcode.c (rb_econv_open0): remove unused codeYusuke Endoh2019-07-241-15/+4
| | | | Coverity Scan found this.
* transcode.c (rb_trans_conv): remove unnecessary assignmentsYusuke Endoh2019-07-141-2/+0
| | | | This change will suppress Coverity Scan warnings
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-3/+2
| | | | | | | Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix call-seq of Encoding::Converter#putback [ci skip]kazu2018-11-011-1/+1
| | | | | | | | [Fix GH-1999] From: Takayuki Matsubara <takayuki.1229@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-09-291-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* transcode.c: add GC guard on raiseshirosaki2018-09-291-2/+6
| | | | | | | | * transcode.c (econv_s_search_convpath): add GC guard to fix SEGV on raise. [Bug #15162] [ruby-core:89172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] missing docs at toplevelnobu2018-02-231-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby/ruby.h: remove unnecessary exports from C-APInormal2018-01-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Needlessly exporting can reduce performance locally and increase binary size. Increasing the footprint of our C-API larger is also detrimental to our development as it encourages tighter coupling with our internals; making it harder for us to preserve compatibility. If some parts of the core codebase needs access to globals, internal.h should be used instead of anything in include/ruby/*. "Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote: > On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote: > > shyouhei@ruby-lang.org wrote: > >> https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908 > >> > >> export rb_mFConst > > > > Why are we exporting all these and making the public C-API bigger? > > If anything, we should make these static. Thanks. > > No concrete reason, except they have already been externed in 2.5. > These variables had lacked declarations so far, which resulted in their > visibility to be that of extern. The commit is just confirming the status quo. > > I'm not against to turn them into static. This reverts changes from r61910, r61909, r61908, r61907, and r61906. * transcode.c (rb_eUndefinedConversionError): make static (rb_eInvalidByteSequenceError): ditto (rb_eConverterNotFoundError): ditto * process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto * file.c (rb_mFConst): ditto * error.c (rb_mWarning, rb_cWarningBuffer): ditto * enumerator.c (rb_cLazy): ditto [Misc #14381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/encoding.hnobu2018-01-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `$SAFE` as a process global state. [Feature #14250]ko12017-12-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/net/http/header.rb: Fix typo. [ci skip][fix GH-1407]hsbt2016-08-161-2/+2
| | | | | | * transcode.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* transcode.c: scrub in the given encodingnobu2016-05-271-1/+1
| | | | | | | | * transcode.c (str_transcode0): scrub in the given encoding when the source encoding is given, not in the encoding of the receiver. [ruby-core:75732] [Bug #12431] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* transcode.c: GC guardsnobu2016-05-221-13/+27
| | | | | | | | * transcode.c (enc_arg, str_transcode_enc_args, econv_args): remove volatile, and add GC guards in callers. [ruby-core:75664] [Bug #12411] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e