Граф коммитов

362 Коммитов

Автор SHA1 Сообщение Дата
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu fdfb939d72 transcode.c: use string
* 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
2014-08-03 01:55:32 +00:00
ktsj 3b895e8355 * process.c (rlimit_resource_type, rlimit_resource_value):
get rid of inadvertent dynamic symbol pin-down.

* re.c (match_backref_number): ditto.

* signal.c (esignal_init, rb_f_kill, trap_signm): ditto.

* transcode.c (econv_opts): ditto.

* vm_trace.c (symbol2event_flag): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-30 13:17:45 +00:00
normal 0a2c4b4c2a rb_econv_t: reduce to 184 bytes from 200 on 64-bit
* transcode.c (rb_econv_t): reduce to 184 bytes from 200 on 64-bit

This allows rb_econv_t to fit inside of three cache lines on x86-64.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-20 04:51:35 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
naruse 95a6be1a17 * transcode.c (str_transcode0): don't scrub invalid chars if
str.encode doesn't have explicit invalid: :replace.
  workaround fix for see #8995

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 08:50:14 +00:00
nobu e8d2806cfc transcode.c: fix segv in String.encode!
* transcode.c (str_transcode0): fix segv in String.encode!.  now
  rb_str_scrub() can return nil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 12:12:44 +00:00
nobu adbdd97d28 string.c: export rb_str_scrub
* string.c (rb_str_scrub): export with fixed length arguments, and
  allow nil as replacement string instead of omitting.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 07:55:56 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
nobu 7ce11f57ed transcode.c: add rb_econv_append
* transcode.c (rb_econv_append): new function to append a string data
  with converting its encoding.  split from rb_econv_substr_append.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06 02:45:50 +00:00
nobu a3a7645f19 transcode.c: do while loop
* transcode.c (rb_econv_substr_append): move loop condition after the
  conversion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06 02:29:17 +00:00
nobu a4eae61521 transcode.c: GC guard
* transcode.c (rb_econv_substr_append): prevent src from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-06 01:29:21 +00:00
nobu 8b8cce322b encoding.c: refill terminator at associating encoding
* encoding.c (rb_enc_associate_index): refill the terminator if it
  becomes longer than before.  [ruby-dev:47500] [Bug #8624]
* string.c (str_null_char, str_fill_term): get rid of out of bound
  access.
* string.c (rb_str_fill_terminator): add a parameter for the length of
  new terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-12 07:28:40 +00:00
nobu 18030d18cf transcode.c: fill terminator
* transcode.c (str_encode_associate): fill terminator after conversion.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 11:18:10 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
naruse 394d5dfa9b * string.c (str_scrub): add ruby method String#scrub which verify and
fix invalid byte sequence.

* string.c (str_compat_and_valid): check given string is compatible
  and valid with given encoding.

* transcode.c (str_transcode0): If invalid: :replace is specified for
  String#encode, replace invalid byte sequence even if the destination
  encoding equals to the source encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-19 17:50:38 +00:00
kazu dbec401c11 use INT2FIX(0) instead of INT2NUM(0).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 16:31:19 +00:00
drbrain 0051369ba3 * hash.c (rb_env_size): Restored documentation for ENV.size
* lib/drb/drb.rb:  Documented DRb::DRb#run.

* lib/erb.rb (class ERB):  Improved documentation of ERb.

* transcode.c:  Documented Encoding::Converter constants.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-26 03:58:33 +00:00
akr a06cddb466 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 13:52:13 +00:00
duerst 463633e4a9 transcode.c (documentation for str_encode): Explain
that transcoding to the same encoding is a no-op
  (i.e. no exceptions, no replacements,...).
  [ruby-core:43557][Bug #6190]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-23 06:12:02 +00:00
nobu 2b84626193 * transcode.c (str_encode_bang, encoded_dup): if nothing was
transcoded, just set encoding but leave coderange unchanged as
  forcee_encoding.  [ruby-core:43557][Bug #6190]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-22 14:14:39 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
tadf cb5217088b trivial changes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-03 03:29:01 +00:00
nobu 4474c83a9d * transcode.c (str_encode): about the extension of :fallback
option since 1.9.3.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14 06:28:32 +00:00
nobu 8baffe6ef6 * class.c (rb_obj_methods), compile.c (iseq_compile_each),
iseq.c(iseq_load, rb_iseq_parameters), pack.c (pack_pack),
  regcomp.c (is_not_included, update_string_node_case_fold),
  transcode.c (rb_econv_open0, make_replacement),
  vm_eval.c (raise_method_missing): remove unused variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:50:12 +00:00
duerst ed73a902b8 transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-30 11:03:22 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
nobu fecda0d9f7 * encoding.c (require_enc): reject only loading from untrusted
load paths.  [ruby-dev:44541] [Bug #5279]
* transcode.c (load_transcoder_entry): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-25 07:54:35 +00:00
nobu 6572bd3ce9 * transcode.c (rb_declare_transcoder, load_transcoder_entry): no
longer need to limit the length of transcoder library name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-07 22:44:27 +00:00
nobu e240f49073 * transcode.c (load_transcoder_entry): concatenate paths directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-06 06:55:30 +00:00
nobu 3a6c3a672f * encoding.c (load_encoding): predefined encoding names are safe.
[ruby-dev:44469] [Bug #5279]
* transcode.c (load_transcoder_entry): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-06 04:15:49 +00:00
nobu a1c5ebe787 * transcode.c: enabled econv newline option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-06 03:07:16 +00:00
nobu bc17dba00f * transcode.c (rb_econv_binmode): newline decorators are
exclusive.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05 09:10:58 +00:00
nobu 7dc7da3d86 * io.c (validate_enc_binmode, prep_stdio): default to text mode on
dosish platforms.  [ruby-core:38822] [Bug #5164]
* transcode.c (rb_econv_prepare_options): keep default ecflags
  unchanged if no options.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-02 12:11:17 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
nobu f41dcd486e * transcode.c (econv_init): revert r31353. [ruby-dev:43512]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 12:04:32 +00:00
nobu c26ab1ef1c * transcode.c (econv_opts): add newline option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-26 15:55:58 +00:00
nobu 8761467727 * io.c (validate_enc_binmode, rb_io_extract_modeenc): set newline
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
2011-04-26 15:55:21 +00:00
nobu 3b937bbdc4 * include/ruby/encoding.h (ECONV_NEWLINE_DECORATOR_MASK): add.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-26 15:54:14 +00:00
nobu 7140c8f0cd * transcode.c (econv_init): fix rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-26 15:52:35 +00:00
nobu e9cc518446 * transcode.c (encoded_dup): extract.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-05 00:38:15 +00:00
akr 41c93065da * transcode.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-09 11:38:55 +00:00
drbrain 457e481b20 Alter comment on String#encode for better wording and ri output
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-16 19:20:51 +00:00
nobu 5bf72d1fa6 * transcode.c (transcode_loop): call default handler of the given
hash, method, proc or [] method as fallback.  [ruby-dev:42692]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-07 13:05:26 +00:00
nobu 23e8deaf0d * array.c, gc.c, hash.c, object.c, string.c, struct.c,
transcode.c, variable.c, vm.c, vm_insnhelper.c, vm_method.c:
  replace calls to rb_error_frozen() with rb_check_frozen().  a
  patch from Run Paint Run Run at [ruby-core:32014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-24 08:14:05 +00:00
nobu 671b498070 Commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:25:29 +00:00
nobu 12cbb58819 * test/ruby/test_sprintf.rb: fix ML ref. [ruby-core:32848]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:22:03 +00:00