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

225 Коммитов

Автор SHA1 Сообщение Дата
matz 7ff7bcbf9d * enum.c (inject_i): use rb_yield_values.
* enum.c (each_with_index_i): ditto.

* eval.c (rb_yield_splat): new function to call "yield *values".

* string.c (rb_str_scan): use rb_yield_splat().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-22 08:09:58 +00:00
matz 808aa5f318 * lib/shell/command-processor.rb (Shell::CommandProcessor::rmdir):
simple typo.

* string.c (str_new4): ptr may refer null_str.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-05 09:27:21 +00:00
matz 029e9449ce * ruby.c (proc_options): -F set compiled regular expression to $;.
[ruby-talk:77381]

* string.c (Init_String): no setter type check for $;


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-30 07:08:56 +00:00
matz dbe85f1ef0 * string.c (rb_str_chomp_bang): defer rb_str_modify() to actual
modify point.  other methods, replace, tr, delete, squeeze,
  lstrip, and rstrip as well.

* string.c (rb_str_rstrip_bang): remove trailing '\0' at the end
  of string.

* string.c (rb_str_lstrip_bang): do not strip '\0' from the left.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-27 17:20:29 +00:00
matz e02b469de1 * eval.c (thgroup_add): no warning for terminated threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-24 05:18:47 +00:00
matz 2436525ed8 * string.c (rb_str_lstrip_bang): strip NUL along with white
spaces. [ruby-talk:76659]

* string.c (rb_str_rstrip_bang): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-23 06:48:52 +00:00
matz fa284f8127 * string.c (rb_str_equal): should return nil for non string
operand to conform comparable convention. [ruby-dev:20759]

* object.c (rb_equal): preserve nil if "==" returns nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-21 18:37:07 +00:00
matz e4de8e7566 * string.c: use StringValueCStr to retrieve paths to system calls.
* string.c (rb_string_value_cstr): check null byte in the string
  before retrieving C ptr.  accessed via macro StringValueCStr.

* file.c (sys_fail2): raise error for two operand system calls
  such as rename, link, symlink.  (ruby-bugs PR#1047)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-20 17:17:52 +00:00
matz fe4de8b4b8 * string.c (rb_str_match2): add warning to "~string".
[ruby-list:37751]

* lib/net/ftp.rb (Net::FTP::open): takes block.  suggested by Gavin
  Sinclair in [ruby-core:01237].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-19 17:26:04 +00:00
matz 9d22a06ea0 * array.c (rb_values_at): extract common procedure from
rb_ary_values_at.  follow DRY principle.

* re.c (match_values_at): values_at should understand ranges.

* struct.c (rb_struct_values_at): ditto.

* struct.c (inspect_struct): inspect format changed; add "struct "
  at the top.

* sprintf.c (rb_f_sprintf): "%p" specifier for inspect output.
  (RCR#68)

* eval.c (rb_mod_undef_method): allow "undef_method" to accept
  multiple arguments. (RCR#146)

* lib/timeout.rb: put timeout in Timeout module. (RCR#121)
  [ruby-talk:61028]

* re.c (match_groups): new method added. (RCR#139)

* variable.c (rb_mod_const_of): should exclude constant defined
  in Object, unless retrieving constants of Object.

* string.c (rb_str_new4): do not allocate new string if original
  is frozen or already have copy-on-write entry. [ruby-talk:74940]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-03 11:02:53 +00:00
matz 447578a8a0 * string.c (rb_str_shared_replace): clear flags before copy.
* string.c (rb_str_replace): ditto.

* eval.c (rb_yield_0): override visibility mode for module_eval
  etc. (ruby-bugs-ja PR#505)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-02 04:27:29 +00:00
nobu 057dcc0495 * string.c (rb_str_split_m): remove white spaces on the head of
the last element, when limit is specified.  [ruby-talk:74506]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-27 05:41:28 +00:00
nobu 7a425f71e3 * io.c (io_fflush): need to check if closed after thread switch.
[ruby-dev:20351]

* io.c (fptr_finalize): ditto.

* string.c (rb_str_rindex_m): fixed wrong fix.  should move backward
  first only when matching from the end.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-26 18:24:58 +00:00
nobu d061e2aab7 sorry, typo again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:45:59 +00:00
nobu 61927637e8 typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:45:09 +00:00
nobu 69459d98ef * dir.c (find_dirsep): get rid of warnings.
* eval.c (error_print): temporary value might be disposed by GC.

* hash.c (env_has_value, env_index): should not increment NULL.

* io.c (io_read, rb_io_sysread): not read when length is 0.

* io.c (rb_io_reopen): ensure initialized IO.

* io.c (rb_io_init_copy): sychronize file pointer.

* io.c (rb_io_s_pipe): make exception proof.

* string.c (rb_str_rindex_m): Fixnum 0 matched end of string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:41:07 +00:00
matz 67dcad92b7 * string.c (rb_str_upto): generate sequence according to "succ"
order.  formerly check was done by dictionary order.
  [ruby-talk:74138]

* string.c (rb_string_value): fill constant empty string along
  with setting ELTS_SHARED if str->ptr is NULL. [ruby-core:01179]

* string.c (rb_string_value_ptr): ditto.

* string.c (rb_check_string_type): ditto.

* string.c (str_gsub): move END(0) check before mbclen2().

* string.c (scan_once): reduce END(0) check.

* io.c (rb_io_initialize): accept fixnum mode.

* eval.c (error_print): replace strchr() by memchr(), einfo may
  contain "\0".

* pack.c (pack_unpack): range check for "@" move; initialize check
  for "m".

* error.c (syserr_initialize): avoid buffer overflow.

* file.c (rb_file_s_readlink): expand buffer until readlink
  succeed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 06:52:39 +00:00
matz b4fd4d6018 * eval.c (Init_Proc): Block/Proc separation. [huge change]
* eval.c (block_arity): returns exact arity number for Procs out
  of methods. also gives 1 for {|a|..}.

* string.c (rb_str_match): revert use of String#index for
  invocation like string =~ string.

* eval.c (rb_Array): move Object#to_a exclusion hack from
  splat_value().  need to be in eval.c for a while.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-26 08:22:33 +00:00
aamine e08bc0a22a * class.c: add #include "version.h".
* hash.c: ditto.
* string.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19 07:11:48 +00:00
matz 6e52d10fe6 * object.c (init_copy): rename copy_object as initialize_copy,
since it works as copy constructor.

* eval.c (rb_add_method): initialize_copy should always be
  private, like initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19 05:41:08 +00:00
matz 776e2693e7 * string.c (rb_str_ljust): now takes optional argument to specify
pad string. [ruby-talk:70482]

* string.c (rb_str_rjust): ditto.

* string.c (rb_str_center): ditto.

* string.c (rb_str_justify): utility function.

* eval.c (rb_add_method): call singleton_method_added or
  method_added for every method definition (after ruby_running).
  [ruby-talk:70471]

* array.c (rb_ary_reverse_bang): Array#reverse! should not return
  nil even for arrays sized less than 2.

* io.c (argf_eof): should not block after reading all argument
  files. (ruby-bugs-ja PR#449)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-02 06:41:33 +00:00
nobu 93695ed08a * string.c (rb_str_to_i): disallow negative radix.
[ruby-dev:20087]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-27 14:13:25 +00:00
matz f34f20ebc5 * rubyio.h (struct OpenFile): add error raise flag to finalizer.
* io.c (Init_IO): define $/, $-0, and $\ as string-only
  variables.

* string.c (rb_str_split_m): does not generate empty string if
  there's no match in the receiver.

* io.c (fptr_finalize): should raise error on EBADF for readable
  IOs as well.

* file.c (rb_stat): use rb_check_convert_type() to retrieve IO.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-14 09:04:43 +00:00
nobu 3f4472433d * bignum.c (rb_cstr_to_inum, rb_big2str): allow 2-36 as radix.
* numeric.c (rb_fix2str): ditto.

* string.c (rb_str_to_i): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-14 06:54:27 +00:00
nobu 1072ad1c2b * string.c (rb_str_capitalize_bang): check length before upcase
first character.  (ruby-bugs:PR#697)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-03-26 18:26:45 +00:00
matz 9d77639f30 * parse.y (dsym): :"symbol string" style should not contain `\0'.
* process.c (proc_detach): new method Proc#detach(pid) which
  create background watcher thread to issue waitpid. [new]

* process.c (rb_detach_process): utility function to detach
  process from C code.

* ext/pty/pty.c (pty_finalize_syswait): terminate watcher thread,
  and detach child process (by creating new idle waitpid watcher
  thread).

* ext/pty/pty.c (pty_syswait): may lost signal stopped child.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-03-07 05:59:42 +00:00
matz e5c5576aeb * string.c (str_new): need no MEMZERO().
* numeric.c (fix_gt): use rb_num_coerce_cmp() instead of
  rb_num_coerce_bin.

* numeric.c (fix_ge, fix_lt, fix_le): ditto.

* numeric.c (flo_gt, flo_ge, flo_lt, flo_le): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-27 08:04:32 +00:00
matz ca014ae071 * string.c (rb_str_cmp_m): should use LONG2NUM().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-21 09:32:18 +00:00
matz b3686317a7 * string.c (rb_str_cmp_m): two small bugs fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-21 03:52:27 +00:00
matz 64db238388 * string.c (rb_str_cmp_m): return nil if str2 does not respond to
both "to_str" and "<=>".

* compar.c (cmp_gt): return nil if "<=>" returns nil (means
  incomparable).

* compar.c (cmp_ge): ditto.

* compar.c (cmp_lt): ditto.

* compar.c (cmp_between): use RTEST(), since cmp_lt and cmp_gt may
  return nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-20 20:40:20 +00:00
matz ab24be4e98 * array.c (rb_ary_to_a): return value should be an Array if the
receiver is an instance of subclass of Array.

* string.c (rb_str_to_s): return value should be a String if the
  receiver is an instance of subclass of String.

* eval.c (rb_call): calls method_missing when superclass method
  does not exist.

* eval.c (rb_f_missing): now handles "no super" case.

* object.c (rb_obj_ivar_get): Object#instance_variable_get: new
  method to get instance variable value without eval(). [new]

* object.c (rb_obj_ivar_set): Object#instance_variable_set: new
  method to set instance variable value without eval(). [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-10 09:40:13 +00:00
nobu a4d9a91b96 re-indented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-07 06:36:53 +00:00
nobu 34033db665 * intern.h, re.c (rb_memsearch): returns long.
* string.c (rb_str_index): should return offset position.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-07 06:35:26 +00:00
matz e2b92403d5 * re.c (rb_reg_initialize_m): 3rd argument was ignored.
* string.c (rb_str_count): return 0 for empty string (was
  returning nil).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-06 08:25:12 +00:00
matz 1d5e19f624 * array.c (rb_ary_equal): a == b is true when b is non T_ARRAY
object, if b has "to_ary" and b == a.

* hash.c (rb_hash_equal): a == b is true when b is non T_HASH
  object, if b has "to_hash" and b == a.

* string.c (rb_str_equal): a == b is true when b is non T_STRING
  object, if b has "to_str" and b == a.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-04 07:27:43 +00:00
matz 467035750e * object.c (Init_Object): default Object#=== now calls "=="
internally.

* re.c (rb_reg_initialize_m): should honor option status of
  original regexp.

* array.c (rb_ary_equal): ary2 should be T_ARRAY (no to_ary
  conversion).

* array.c (rb_ary_eql): ditto.

* string.c (rb_str_equal): str2 should be T_STRING (no to_str
  conversion).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-03 08:45:26 +00:00
matz 0c90036fd1 * re.c (rb_memsearch): algolithm body of String#index.
* error.c (Init_Exception): "to_str" removed.

* eval.c (eval): should not rely on Exception#to_str

* eval.c (compile_error): ditto.

* error.c (err_append): ditto.

* hash.c (rb_hash_merge): Hash#merge, non destructive "update".
  now there's also Hash#merge! which is an alias to "update".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-03 05:34:16 +00:00
matz d18922065b * string.c (rb_str_index): search using Karp-Rabin algolithm.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 06:48:54 +00:00
matz 74d5623029 * variable.c (rb_obj_classname): new function.
* string.c (rb_str_dup): should preserve original's class (but not
  hidden singleton class).

* string.c (rb_str_substr): ditto.

* parse.y: backout EXPR_CMDARG removal.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 04:00:17 +00:00
matz f758195486 * parse.y (yylex): remove EXPR_CMDARG according to the RHG book.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 03:15:33 +00:00
michal 9df466b287 Updated Copyrights of Matz to 2003.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-16 07:34:03 +00:00
nobu c39a8e326a * string.c (rb_str_substr): should share the shared string if
present, instead of the original string.  (ruby-bugs:PR#528)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-30 07:55:17 +00:00
usa b469f3155a * array.c (ary_alloc), dir.c (dir_s_alloc), eval.c (thgroup_s_alloc),
file.c (rb_stat_s_alloc), hash.c (hash_alloc), io.c (io_alloc),
  object.c (rb_module_s_alloc, rb_class_allocate_instance),
  re.c (match_alloc, rb_reg_s_alloc), string.c (str_alloc),
  time.c (time_s_alloc), ext/digest/digest.c (rb_digest_base_alloc),
  ext/tcltklib/tcltklib.c (ip_alloc),
  ext/win32ole/win32ole.c (fole_s_allocate, fev_s_allocate)
  : add prototype to get rid of VC++ warnings.

* ext/sdbm/init.c (fsdbm_alloc): allocator takes only one argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-21 18:02:01 +00:00
matz bc49bc7c6b * parse.y (do_block): split "do" block and tLBRACE_ARG block.
* parse.y (cmd_brace_block): new tLBRACE_ARG block rule

* parse.y (command): can take optional cmd_brace_block; use %prec
  to resolve shift/reduce conflict. (ruby-bugs-ja PR#372)

* eval.c (ruby_finalize): trace_func should be cleared here (after
  executing exit procs and finalizers).

* eval.c (rb_define_alloc_func): new allocation framework, based
  on Nobu's work [ruby-dev:19116].  "allocate" method is no longer
  used for object allocation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-20 08:33:17 +00:00
matz baa00aa250 * numeric.c (num_step): use DBL_EPSILON.
* array.c (rb_check_array_type): new function: return an array
  (convert if possible), or nil.

* string.c (rb_check_string_type): new function: return a string
  (convert if possible), or nil.

* numeric.c (rb_dbl_cmp): returns nil if values are not
  comparable.

* numeric.c (fix_cmp,flo_cmp): use rb_num_coerce_cmp()

* bignum.c (rb_big_cmp): ditto.

* numeric.c (rb_num_coerce_cmp): new coercing function for "<=>",
  which does not raise TypeError.

* numeric.c (do_coerce): can be supress exception now.

* object.c (rb_mod_cmp): should return nil for non class/module
  objects.

* re.c (rb_reg_eqq): return false if the argument is not a
  string.  now returns boolean value.

* class.c (rb_include_module): argument should be T_MODULE, not
  T_class, nor T_ICLASS.

* eval.c (is_defined): "defined?" should return "assignment" for
  attribute assignment (e.g. a.foo=b) and indexed assignment
  (e.g. a[2] = 44).

* parse.y (aryset): use NODE_ATTRASGN.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-19 09:20:20 +00:00
nobu f8c8a38d30 * string.c (rb_str_dup_frozen): handle tail shared string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-18 11:50:49 +00:00
nobu f4b8bbb143 * string.c (rb_str_new4): handle tail shared string.
(ruby-bugs-ja:PR#370)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-17 18:20:46 +00:00
nobu 86db656415 * node.h (NODE_ATTRASGN): new node, assignment to attribute.
[ruby-core:00637].

* eval.c (is_defined, rb_eval): ditto.

* parse.y (attrset, node_assign): ditto.

* string.c (rb_str_substr): tail sharing.  [ruby-core:00650]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-17 10:34:30 +00:00
matz 60b2446bea * sprintf.c (rb_f_sprintf): preceding ".." for negative numbers
still left;  removed.

* sprintf.c (rb_f_sprintf): should not prepend '0' if width > prec
  for example "%5.3d".

* process.c (Init_process): add Process.exit and Process.abort

* pack.c (utf8_to_uv): raise ArgumentError for malformed/redundant
  UTF-8 sequences.

* process.c (last_status_set): add pid attribute to Process::Status.

* pack.c (uv_to_utf8): limit maximum length of the encoded string
  to 6 bytes, even when the platform supports 8 bytes long integers.

* pack.c (utf8_to_uv): do not decode sequences longer than 6 bytes.

* object.c (copy_object): use "copy_object" method, not "become".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-10 06:23:44 +00:00
matz aae36756dc * object.c (Init_Object): added Object#object_id, new name for
Object#id. [new]

* object.c (rb_obj_id_obsolete): give warning for Object#id.

* numeric.c (fix_intern): added Fixnum#to_sym. [new]

* object.c (sym_to_sym): rename from Symbol#intern

* enum.c (enum_zip): added Enumerable#zip. [new]

* array.c (rb_ary_zip): added Array#zip.

* error.c (init_syserr): remove sys_nerr dependency.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-11-03 11:04:35 +00:00
aamine 42e292ae33 * string.c (rb_str_split_m): RSTRING(str)->ptr might become NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-10-24 17:54:53 +00:00
nobu d4f2f6a7f7 * eval.c (rb_eval): added NODE_DSYM, symbol literal with
interpolation.

* node.h: ditto.

* intern.h: prototypes; rb_is_junk_id, rb_str_dump, rb_str_intern

* object.c (sym_inspect): escape and quote for non-alphanumeric
  symbols.

* parse.y (dsym, tokadd_string, yylex): extended symbol literals.

* parse.y (rb_is_junk_id): added.

* string.c (rb_str_dump, rb_str_intern) : make extern.

* lib/mkmf.rb (create_makefile): deffile should be removed by
  distclean, not clean.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-10-23 10:17:30 +00:00
matz 4b9a7eac05 * io.c (appendline): forget to terminate with nul.
* eval.c (ruby_run): should set toplevel visibility again here.

* eval.c (rb_eval): should not rely on ruby_class == rb_cObject
  check.   Besides allow implicit publicity for attribute set
  methods.

* parse.y (primary): need not to check class_nest, just set
  whether method is an attrset or not.

* string.c (rb_str_each_line): p might be at the top of the
  string.

* class.c (rb_make_metaclass): class of metaclass should be
  metaclass of superclass, unless class itself is a metaclass;
  class of metaclass of metaclass should point back to self.
  eh, confusing, isn't it.

* class.c (rb_singleton_class): check if its class is singleton
  AND attached to self.

* eval.c (rb_eval): should define class/module under ruby_cbase.

* eval.c (rb_eval): should set class/module path based on
  ruby_cbase, not ruby_class.

* eval.c (module_setup): use ruby_cbase instead of ruby_class.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-25 07:03:05 +00:00
michal 449f885d62 Fix-Addons [ruby-core:483] with corrections from [ruby-core:484]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-13 08:26:35 +00:00
matz b031fdbc0e * dir.c (glob_helper): prevent memory leak using rb_protect().
* string.c (rb_str_associate): no need to check freeze flag.

* string.c (rb_str_resize): should honor STR_ASSOC flag on
  resize.

* string.c (rb_str_resize): proper STR_ASSOC handling.  pointed
  out by Michal Rokos.

* string.c (rb_str_buf_cat): ditto.

* string.c (rb_str_cat): ditto.

* string.c (rb_str_buf_append): ditto.

* string.c (rb_str_append): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-12 06:27:15 +00:00
knu b9e3aa30f7 * string.c (get_pat): Add an extra argument "quote".
* string.c (rb_str_match_m): Do not bother to convert if a regexp
  is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-11 04:05:36 +00:00
matz 6f484e4930 * variable.c (rb_copy_generic_ivar): remove old generic instance
variable table if it existes.

	* class.c (rb_make_metaclass): metaclass of a metaclass is a
	  metaclass itself.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-03 05:20:14 +00:00
matz 40bc4f5ae4 * array.c (rb_ary_become): should not free ptr if it's shared.
* eval.c (rb_alias): prohibit making an alias named "allocate" if
  klass is a metaclass.

* string.c (rb_string_value_ptr): StringValuePtr() should never
  return NULL pointer.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-29 09:08:18 +00:00
michal 0d0ae37e50 Int vs Long cleanup #3 (ruby-core:352)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-28 08:05:23 +00:00
matz 1a44a463af * string.c (rb_str_delete_bang): should check if str->ptr is 0.
* string.c (rb_str_squeeze_bang): ditto.

* string.c (rb_str_count): ditto.

* string.c (rb_str_lstrip_bang): ditto.

* string.c (rb_str_rstrip_bang): ditto.

* string.c (rb_str_intern): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-28 06:01:58 +00:00
eban 087f010ddb * string.c (rb_str_rstrip_bang): don't access address -1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-27 10:24:24 +00:00
matz c45908e41f * file.c (rb_find_file): $LOAD_PATH must not be empty.
* file.c (rb_find_file_ext): ditto.

* range.c (range_eq): class check should be based on range.class,
  instead of Range to work with Range.dup.

* range.c (range_eql): ditto.

* class.c (rb_mod_dup): need to preserve metaclass and flags.

* object.c (rb_cstr_to_dbl): had a buffer overrun.

* marshal.c (w_class): integrate singleton check into a funciton
  to follow DRY principle.

* marshal.c (w_uclass): should check singleton method.

* object.c (rb_obj_dup): dmark and dfree functions must be match
  for T_DATA type.

* object.c (rb_obj_dup): class of the duped object must be match
  to the class of the original.

* re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are
  not regular expression metacharacters.

* time.c (time_s_alloc): use time_free instead of free (null check,
  also serves for type mark).

* time.c (time_s_at): check dfree function too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-27 08:31:08 +00:00
michal ffc13a6525 *.c: Int vs Long cleanup
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-21 15:47:54 +00:00
usa fc2a1ad79f * string.c (rb_str_rindex): must return -1 if unmatched.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-06 06:20:43 +00:00
matz 7194b66fb2 * random.c: replace with Mersenne Twister RNG.
* eval.c (jump_tag_but_local_jump): preserve retval in
  LocalJumpError exceptions.

* parse.y (command): no more check for "super outside of method".

* eval.c (rb_mod_define_method): should set last_class and
  last_func in the block->frame.

* eval.c (error_handle): should handle TAG_THROW as well.

* parse.y (yylex): new decimal notation '0d4567'.

* parse.y (yylex): new octal notation '0o777'.

* parse.y (string_content): every string_content node should
  return string only.  use NODE_EVSTR to coercing.

* eval.c (rb_eval): NODE_EVSTR support.

* re.c (rb_reg_quote): avoid unnecessary string allocation.

* string.c (get_pat): quote metachracters before compiling a
  string into a regex.

* string.c (rb_str_split_m): special treatment of strings of size
  1, but AWK emulation.  now uses get_pat().

* string.c (rb_str_match_m): quote metacharacters.

* string.c (rb_str_match2): ditto.

* ext/socket/socket.c (sock_addrinfo): make all 3 versions of
  getaddrinfo happy.  [ruby-core:00184]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-07-26 06:12:39 +00:00
nobu ad9d3f9655 * string.c (rb_str_match): fix for string match.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-07-11 17:17:14 +00:00
matz be1d2c5f68 * string.c (rb_str_slice_bang): if there's no corresponding
substring, slice! should return nil without exception.

* array.c (rb_ary_insert): type fixed.

* string.c (rb_str_split_m): accept separator value nil as well.

* string.c (rb_str_become): was leaking memory.

* class.c (rb_include_module): should not alter other
  classes/modules by inclusion.  by this fix, local order may not
  be preserved for some cases.

* class.c (include_class_new): module may be T_ICLASS; retrieve
  original module information.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-07-11 08:22:18 +00:00
matz 1979d9ae1f * parse.y (yylex): obsolete '?<whitespace>'; use '?\s', '?\n',
etc, instead.

* parse.y (yylex): no here document after a dot.

* parse.y (yylex): should have set lex_state after '`'.

* parse.y (yylex): should have set lex_state properly after
  tOP_ASGN.

* bignum.c (rb_big2dbl): return canonical HUGE_VAL for infinity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-18 06:29:07 +00:00
matz b7bc0cae53 * string.c (rb_str_aset): should raise error if an indexing string
is not found in the receiver.

* sprintf.c (rb_f_sprintf): "%d" should convert objects into
  integers using Integer().

* lib/tempfile.rb (Tempfile::size): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-06-04 07:34:19 +00:00
matz 4ab1577db3 * parse.y: yyparse #defines moved from intern.h
* ruby.c (proc_options): access prefixed "ruby_yydebug".

* applied modifies to pacify some of gcc -Wall warnings.

* parse.y (arg): no more ugly hack for "**", so that "-2**2" to be
  parsed as "(-2)**2", whereas "- 2**2" or "-(2)**2" to be parsed
  as "-(2**2)".

* parse.y (yylex): '-2' to be literal fixnum. [new]

* time.c (time_succ): new method for Range support.

* time.c (time_arg): nil test against v[6] (usec).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-05-29 05:20:39 +00:00
michal bab153b243 * array.c: fixed format string for 'long' args (%d -> %ld).
* class.c: ditto.

	* eval.c: ditto.

	* numeric.c: ditto.

	* pack.c: ditto.

	* parse.y: ditto.

	* range.c: ditto.

	* string.c: ditto.

	* util.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-05-28 18:11:07 +00:00
matz e3a8c62630 * io.c (rb_io_mode_flags): both 'r+b' and 'rb+' should be allowed.
* io.c (rb_io_mode_modenum): ditto.

* gc.c (rb_memerror): rename from mem_error, and exported.

* gc.c (Init_GC): pre-allocate NoMemoryError instance.

* object.c (convert_type): error message changed from "failed to
  convert" to "cannot convert", since it does not try to convert
  if an object does not respond to the converting method.

* eval.c (block_pass): convert Method to Proc using
  rb_check_convert_type().

* object.c (rb_check_convert_type): always convert T_DATA

* eval.c (rb_thread_cleanup): should not terminate main_thread by
  Fatal error.

* regex.c (is_in_list): need to not exclude NUL and NEWLINE.

* re.c (rb_reg_expr_str): wrong backslash escapement.

* re.c (rb_reg_expr_str): do not escape embedded space
  characters.

* marshal.c (w_object): T_DATA process patch from Joel VanderWerf
  <vjoel@PATH.Berkeley.EDU>.  This is temporary hack; it remains
  undocumented, and it will be removed when marshaling is
  re-designed.

* marshal.c (r_object): ditto.

* numeric.c (num_step): Integer#step is moved to Numeric#step;
  Fixnum#step is merged into this method.

* numeric.c (int_dotimes): Fixnum#times is merged.

* numeric.c (int_upto): Fixnum#upto is merged.

* numeric.c (int_downto): Fixnum#downto is merged.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-04-24 04:54:16 +00:00
matz e63a990141 * re.c (rb_reg_expr_str): should treat backslash specially in
escaping.

* io.c: complete off_t handling; missing argument for
  fptr_finalize(); polished rb_scan_args call.

* dir.c: wrap multi-statment macro by do { } while (0)

* eval.c, numeric,c, sprintf.c, util.c: ditto.

* bignum.c (rb_big_eq): check `y == x' if y is neither Fixnum,
  Bignum, nor Float.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-04-18 08:46:18 +00:00
matz 6d2e56ce7c * re.c (rb_reg_search): should clear last_match if pos is out of
string range.

* string.c (rb_str_index_m): ditto.

* string.c (rb_str_rindex): ditto.

* class.c (rb_define_class): should handle autoload.

* class.c (rb_define_module): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-19 09:03:11 +00:00
nobu bce7601f73 * string.c (rb_str_subpat_set): must make str independent after
rb_reg_search() matched.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-14 00:10:49 +00:00
matz 86c6af5873 * marshal.c (w_object): module inclusion using extend() should
also be detected.

* eval.c (rb_eval_cmd): cbase should not be NULL; it should be
  either ruby_wrapper or Object.

* enum.c (enum_each_with_index): should return self.

* process.c (proc_setpgrp): should return value for non-void function.

* process.c (proc_getpgid): should raise exception if getpgid() return -1.

* string.c (rb_str_ljust): should return a duplicated string.

* string.c (rb_str_rjust): ditto.

* string.c (rb_str_center): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-03-11 08:02:04 +00:00
nobu c2269d5b4f * intern.h: prototypes for new functions; rb_cstr_to_inum(),
rb_str_to_inum(), rb_cstr_to_dbl(), rb_str_to_dbl()

* bignum.c (rb_cstr_to_inum): changed from rb_cstr2inum(), and
  added argument badcheck to be consistent with parser. [new]

* bignum.c (rb_str_to_inum): ditto.

* bignum.c (rb_cstr2inum): wapper of rb_cstr_to_inum() now.

* bignum.c (rb_str2inum): ditto.

* object.c (rb_cstr_to_dbl): float number parser. [new]

* object.c (rb_str_to_dbl): ditto.

* object.c (rb_Float): use rb_cstr_to_dbl() for strict check.

* object.c (rb_Integer): use rb_str_to_inum() for strict check.

* string.c (rb_str_to_f): use rb_str_to_dbl() with less check.

* string.c (rb_str_to_i): use rb_str_to_inum() with less check.

* string.c (rb_str_hex): ditto.

* string.c (rb_str_oct): ditto.

* sprintf.c (rb_f_sprintf): ditto.

* time.c (obj2long): ditto.

* parse.y (yylex): use rb_cstr_to_inum() for strict check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-02-01 10:23:22 +00:00
matz 4f38c453b4 * eval.c (is_defined): defined?(Foo::Baz) should check constants
only, no methods.

* eval.c (is_defined): should not dump core on defined?(a::b)
  where a is not a class nor a module.

* object.c (Init_Object): remove dup and clone from TrueClass,
  FalseClass, and NilClass.

* array.c (rb_ary_fill): Array#fill takes block to get the value to
  fill.

* string.c (rb_str_to_i): to_i(0) auto-detects base radix.

* array.c (rb_ary_initialize): fill by the block evaluation value
  if block is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-01-28 08:44:45 +00:00
matz f547c1150c * class.c (rb_include_module): detect cyclic module inclusion.
* eval.c (rb_thread_cleanup): need not to free thread stacks at
  process termination.

* array.c (rb_ary_fetch): use the block to get the default value
  if the block is given.

* eval.c (rb_thread_schedule): should check time only if BOTH
  WAIT_SELECT and WAIT_TIME.

* eval.c (umethod_bind): should update rklass field.

* hash.c (rb_hash_update): if a block is given, yields [key,
  value1, value2] to the block to resolve conflict.

* string.c (rb_str_split_m): no need to consider KANJI
characters, if the length of separator is 1 (byte).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-01-25 08:22:11 +00:00
matz 85e32dd221 * re.c (match_select): should propagate taintness.
* hash.c (rb_hash_set_default): Hash#default= should return the
  new value.

* string.c (rb_str_to_i): accepts optional base argument. [new]

* numeric.c (rb_fix2str): should not handle negative fixnum values
  int32 via calling sprintf() directly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-01-11 09:18:54 +00:00
matz c9f4686694 * string.c (rb_str_new2): NULL pointer check added.
* class.c (rb_define_module_under): should locate predefined
  module using rb_const_defined_at().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-01-07 05:27:01 +00:00
matz ee87eb1367 * eval.c (rb_mod_define_method): define_method should follow
default method visibility.

* eval.c (rb_attr): should warn if the default method visibility
  is "module_function" (can be error).

* eval.c (rb_mod_define_method): should define class/module method
  also if the visibility is "module_function".

* eval.c (rb_mod_define_method): should call hook method
  "method_added", and "singleton_method_added".

* string.c: use RESIZE_CAPA for capacity change.

* ext/socket/socket.c (Init_socket): add listen method to
  TCPServer and UNIXServer.

* ext/socket/socket.c (bsock_send): should raise EWOULDBLOCK
  exception.

* ext/socket/socket.c (s_recvfrom): ditto.

* ext/socket/socket.c (s_accept): ditto.

* ext/socket/socket.c (udp_send): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-19 07:48:32 +00:00
matz 35f851bcfe * string.c (rb_str_replace): swap arguments of OBJ_INFECT.
* eval.c (rb_thread_schedule): should not select a thread which is
  not yet initialized.

* time.c (time_plus): wrong boundary check.

* time.c (time_minus): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-18 08:47:06 +00:00
matz a59c599209 * string.c (rb_str_match_m): should convert an argument into
regexp if it's a string.

* array.c (rb_ary_select): Array#select(n,m,...) now works like
  Array#indexes(n,m,..). [new, experimental]

* hash.c (rb_hash_select): ditto.

* hash.c (env_select): ditto.

* re.c (match_select): ditto.

* struct.c (rb_struct_select): ditto.

* gc.c (STR_ASSOC): use FL_USER3 instead of FL_USER2.

* parse.y (str_extend): make up pushback call.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-11 03:48:08 +00:00
matz 2f8d3bdc21 * array.c (rb_ary_modify): should copy the internal buffer if the
modifying buffer is shared.

* array.c (ary_make_shared): make an internal buffer of an array
  to be shared.

* array.c (rb_ary_shift): avoid sliding an internal buffer by
  using shared buffer.

* array.c (rb_ary_subseq): avoid copying the buffer.

* parse.y (gettable): should freeze __LINE__ string.

* io.c (rb_io_puts): old behavoir restored.  rationale: a) if you
  want to call to_s for arrays, you can just call print a, "\n".
  b) to_s wastes memory if array (and sum of its contents) is
  huge.  c) now any object that has to_ary is treated as an array,
  using rb_check_convert_type().

* hash.c (rb_hash_initialize): now accepts a block to calculate
  the default value. [new]

* hash.c (rb_hash_aref): call "default" method to get the value
  corrensponding to the non existing key.

* hash.c (rb_hash_default): get the default value based on the
  block given to 'new'.  Now it takes an optinal "key" argument.
  "default" became the method to get the value for non existing
  key.  Users may override "default" method to change the hash
  behavior.

* hash.c (rb_hash_set_default): clear the flag if a block is given
  to 'new'

* object.c (Init_Object): undef Data.allocate, left Data.new.

* ext/curses/curses.c (window_scrollok): use RTEST().

* ext/curses/curses.c (window_idlok): ditto.

* ext/curses/curses.c (window_keypad): ditto.

* ext/curses/curses.c (window_idlok): idlok() may return void on
  some platforms; so don't use return value.

* ext/curses/curses.c (window_scrollok): ditto for consistency.

* ext/curses/curses.c: replace FIX2INT() by typechecking NUM2INT().

* parse.y (str_extend): should not process immature #$x and
  #@x interpolation, e.g #@#@ etc.

* enum.c (enum_sort_by): sort_by does not have to be stable always.

* enum.c (enum_sort_by): call qsort directly to gain performance.

* util.c (ruby_qsort): ruby_qsort(qs6) is now native thread safe.

* error.c (rb_sys_fail): it must be a bug if it's called when
  errno == 0.

* regex.c (WC2MBC1ST): should not pass through > 0x80 number in UTF-8.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-12-10 07:18:16 +00:00
matz 23303b8a63 * string.c (rb_str_equal): object with to_str must be treated as a
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-11-29 15:57:25 +00:00
matz 04f27f5e8d * eval.c (rb_mod_modfunc): should follow NODE_ZSUPER link; based
on Guy Decoux's patch in [ruby-talk:25478].

* string.c (rb_str_succ): there was buffer overrun.

* parse.y (str_extend): term can be any character.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-11-19 14:42:45 +00:00
matz df96f994f1 * parse.y (parse_regx): should raise error on untermitated
expression interpolation.

* pack.c (pack_unpack): should give length to utf8_to_uv().

* pack.c (utf8_to_uv): add length check.

* massages: replace "wrong #" by "wrong number".

* marshal.c (w_float): output Infinity and NaN explicitly.

* marshal.c (r_object): support new explicit float format.

* eval.c (rb_thread_wait_for): select may cause ERESTART on
  Solaris.

* eval.c (rb_thread_select): ditto.

* array.c (rb_ary_join): dumped core if sep is not T_STRING nor T_NIL.

* array.c (rb_ary_join): buffer size calculattion was wrong.

* array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines
  between array elements (use rb_default_rs as newline litral)
  [experimental].

* gc.c (init_mark_stack): no need to clear mark_stack.

* gc.c (gc_mark_all): need to handle finalizer mark.

* gc.c (gc_mark_rest): use MEMCPY instead of memcpy.

* gc.c (rb_gc_mark): earlier const check to avoid pusing special
  constants into mark stack.

* numeric.c (fix_to_s): 'to_s' now takes optional argument to
  specify radix. [new]

* bignum.c (rb_big_to_s): ditto. [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-11-19 05:03:03 +00:00
matz 7422ccdd9e * signal.c (sighandle): should not re-register sighandler if
POSIX_SIGNAL is defined.

* eval.c (error_print): errat array may be empty.

* eval.c (rb_eval_cmd): should not upgrade safe level unless
  explicitly specified by argument newly added.

* signal.c (sig_trap): should not allow tainted trap closure.

* variable.c (rb_f_trace_var): should not allow trace_var on safe
  level higher than 3.

* variable.c (rb_f_trace_var): should not allow tainted trace
  closure.

* gc.c: do not use static stack until system stack overflows.

* eval.c (eval): should call Exception#exception instead of
  calling rb_exc_new3() directly.

* error.c (exc_exception): set "mesg" directly to the clone.  it
  might be better to set mesg via some method for flexibility.

* variable.c (cvar_override_check): should print original module
  name, if 'a' is T_ICLASS.

* parse.y (yylex): float '1_.0' should not be allowed.

* variable.c (var_getter): should care about var as Qfalse
  (ruby-bugs#PR199).

* array.c (cmpint): <=> or block for {min,max} may return bignum.

* array.c (sort_1): use rb_compint.

* array.c (sort_2): ditto.

* enum.c (min_ii): ditto.

* enum.c (min_ii): ditto.

* enum.c (max_i): ditto.

* enum.c (max_ii): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-11-13 08:19:52 +00:00
matz dc98adf839 * process.c (security): always give warning for insecure PATH.
* dir.c (my_getcwd): do not rely on MAXPATHLEN.

* file.c (rb_file_s_readlink): ditto.

* file.c (path_check_1): ditto.

* eval.c (rb_yield_0): should not call rb_f_block_given_p().

* string.c (rb_str_chomp_bang): should terminate string by NUL.

* eval.c (rb_yield_0): better error message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-11-08 06:43:14 +00:00
matz c0fe73989d * eval.c (POP_VARS): should not set DVAR_DONT_RECYCLE if _old
ruby_vars is already force_recycled.

* gc.c (rb_gc): handles mark stack overflow.

* gc.c (PUSH_MARK): use static mark stack, no more recursion.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-10-31 06:53:22 +00:00
matz 54d534f043 * string.c (rb_str_chomp_bang): do smart chomp if $/ == '\n'.
* io.c (rb_io_puts): don't treat Array specially.

* bignum.c (rb_big_cmp): should convert bignum to float.

* eval.c (rb_f_eval): can't modify untainted binding.

* regex.c (re_compile_pattern): should preverve p0 value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-10-30 08:43:28 +00:00
matz 5f877e8431 * string.c (rb_str_index): wrong increment for non alphanumeric
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-10-16 03:27:23 +00:00
matz 1fe40b7cc5 * marshal.c (r_object): better allocation type check for
TYPE_UCLASS. usage of allocation framework is disabled for now.

* variable.c (rb_class_path): Module may have subclass.

* string.c (rb_str_update): should maintain original negative
  offset.

* string.c (rb_str_subpat_set): ditto

* string.c (rb_str_aset): ditto.

* re.c (rb_reg_nth_match): should check negative nth.

* re.c (rb_reg_nth_defined): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-10-03 07:19:19 +00:00
matz 75eee0bafd * ext/socket/socket.c (unix_addr): getsockname(2) may result len = 0.
* ext/socket/socket.c (unix_peeraddr): getpeername(2) may result
  len = 0.

* string.c (rb_str_subpat_set): support function for new argument
  pattern String#[re,offset] = val. [new]

* eval.c (POP_BLOCK): rb_gc_force_recycle() was called too much.
  Should not be called if SCOPE_DONT_RECYCLE is set.

* string.c (rb_str_aref_m): new argument pattern
  String#[re,offset]. [new]

* string.c (rb_str_substr): should return an instance of
  receiver's class.

* string.c (rb_str_succ): ditto.

* array.c (rb_ary_subseq): ditto.

* array.c (rb_ary_initialize): Array.new([1,2,3]) => [1,2,3]. [new]

* string.c (rb_str_reverse): should return an instance of
  receiver's class.

* string.c (rb_str_times): ditto.

* array.c (rb_ary_times): ditto

* string.c (str_gsub): ditto.

* string.c (rb_str_ljust): ditto.

* string.c (rb_str_rjust): ditto.

* string.c (rb_str_center): ditto.

* eval.c (eval): retrieves file, line information from binding.

* eval.c (intersect_fds): counts intersecting fds.

* eval.c (rb_thread_schedule): only fds requested by
  each thread count as select_value.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-10-02 04:31:23 +00:00
matz 6767cd760a * string.c (rb_str_init): String.new() => ""
* dir.c (dir_path): new method.

* dir.c (dir_initialize): wrap DIR into struct, along with path
  information.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-09-19 06:54:11 +00:00
matz 67245eec71 * eval.c (rb_thread_restore_context): save current value of
lastline and lastmatch in the thread struct for later restore.

* eval.c (rb_thread_save_context): restore lastline and lastmatch.

* numeric.c (flo_to_s): should handle negative float value.

* class.c (rb_include_module): should check whole ancestors to
  avoid duplicate module inclusion.

* string.c (trnext): should check backslash before updating "now"
  position.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-09-08 14:17:53 +00:00
matz b47a99485b * parse.y (yylex): ternary ? can be followed by newline.
* eval.c (rb_f_require): should check static linked libraries
  before raising exception.

* array.c (rb_ary_equal): check identiry equality first.

* string.c (rb_str_equal): ditto.

* struct.c (rb_struct_equal): ditto.

* numeric.c (Init_Numeric): undef Integer::new.

* eval.c (rb_eval): NODE_WHILE should update result for each
  conditional evaluation.

* eval.c (rb_eval): NODE_UNTIL should return last evaluated value
  (or value given to break).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-08-29 06:28:51 +00:00
matz c786866812 * range.c (range_step): 'iter' here should be an array.
* marshal.c (w_object): should retrieve __member__ data from
  non-singleton class.

* variable.c (rb_cvar_get): class variable override check added.

* variable.c (rb_cvar_set): ditto

* variable.c (rb_cvar_declare): ditto.

* parse.y (parse_regx): handle backslash escaping of delimiter here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-08-20 04:29:58 +00:00
matz 04a8e85bc5 * range.c (range_step): new method.
* string.c (rb_str_cmp): remove needless conditional.

* string.c (rb_str_lstrip_bang) `return Qnil' was missing.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2001-08-14 08:13:31 +00:00