ko1
25c0cb981a
* include/ruby/ruby.h: introduce 2 macros:
...
RFLOAT_VALUE(v), DOUBLE2NUM(dbl).
Rename RFloat#value -> RFloat#double_value.
Do not touch RFloat#double_value directly.
* bignum.c, insns.def, marshal.c, math.c, numeric.c, object.c,
pack.c, parse.y, process.c, random.c, sprintf.c, string.c,
time.c: apply above changes.
* ext/dl/mkcallback.rb, ext/json/ext/generator/generator.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 16:00:53 +00:00
akr
098a563935
* string.c (tr_trans): cast to unsigned char after dereference
...
a pointer to a char to avoid SEGV with "\377".tr("a", "b").
on FreeBSD/amd64.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-10 14:53:26 +00:00
nobu
03d68e3ba4
* string.c (rb_str_squeeze_bang): initialize squeezing table if no
...
arguments given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 06:20:15 +00:00
davidflanagan
f6fb4b3e8e
* string.c (tr_setup_table, tr_trans): fix test failures in test/ruby/test_string.rb
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-07 22:07:13 +00:00
matz
19c4d26c51
* string.c (tr_setup_table): use C array for characters that fit
...
in a byte to gain performance.
* string.c (rb_str_delete_bang): ditto.
* string.c (rb_str_squeeze_bang): ditto.
* string.c (rb_str_count): ditto.
* string.c (tr_trans): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-03 19:04:53 +00:00
nobu
2ae60f1634
* string.c (rb_str_substr): perfomance improvement. [ruby-dev:31806]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-29 08:58:17 +00:00
nobu
b1d53d10e2
* string.c (rb_str_ord): use encoding.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 17:50:51 +00:00
nobu
eb6e9c15bd
* string.c (rb_str_new4): should copy encoding. a patch from NARUSE,
...
Yui <naruse AT airemix.com>. [ruby-dev:32076]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 04:25:47 +00:00
nobu
9c24fed339
* encoding.c (rb_cEncoding): new Encoding class.
...
* encoding.c (rb_to_encoding, rb_to_encoding_index): helper functions.
* encoding.c (rb_obj_encoding): return Encoding object now.
* gc.c (garbage_collect): mark Encoding objects.
* string.c (rb_str_force_encoding): accept Encoding object as well as
encoding name.
* include/ruby/encoding.h (rb_to_encoding_index, rb_to_encoding):
prototypes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-13 16:32:40 +00:00
nobu
8c19ecbeeb
* string.c (rb_enc_str_coderange): fixed checkfor non-ascii.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-10 05:31:08 +00:00
matz
026568c915
* string.c (rb_str_to_i): update RDoc since base can be any value
...
between 2 and 36. [ruby-talk:272879]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 14:17:35 +00:00
nobu
597974c21f
* encoding.c (rb_enc_register): returns new index or -1 if failed.
...
* encoding.c (rb_enc_alias): check if original name is registered.
* encoding.c (rb_enc_init): register in same order as kcode options in
re.c. added new aliases.
* string.c (rb_str_force_encoding): check if valid encoding name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 05:56:09 +00:00
nobu
6845578c92
* insns.def (opt_eq): get rid of gcc bug.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 05:32:37 +00:00
matz
c953283d7e
revert rb_memcmp() change to pacify GCC optimizer
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 09:54:53 +00:00
matz
1677425e9d
* re.c (rb_memcmp): no longer useful without ruby_ignorecase.
...
* re.c (rb_reg_prepare_re): revert recompile condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 09:24:00 +00:00
matz
dbcc539602
* re.c (ignorecase_setter): change warning message.
...
* re.c (ignorecase_getter): now gives warning.
* string.c (rb_str_cmp_m): update RDoc document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 08:09:06 +00:00
nobu
19dee8af57
* encoding.c (rb_obj_encoding): returns encoding of the given object.
...
* re.c (Init_Regexp): new method Regexp#encoding.
* string.c (str_encoding): moved to encoding.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 06:57:19 +00:00
nobu
eb64f5de06
* string.c (rb_str_append): always set encoding, and coderange
...
cache bits.
* include/ruby/encoding.h (ENC_CODERANGE_SET): fixed a bug not to
set chache bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-30 08:13:28 +00:00
matz
43c4d80930
* array.c (rb_ary_combination): new method to give all combination
...
of elements from an array. [ruby-list:42671]
* array.c (rb_ary_product): a new method to get all combinations
of elements from two arrays. can be extended to combinations of
n-arrays, e.g. a.product(b,c,d). anyone volunteer?
* array.c (rb_ary_permutation): empty function body to calculate
permutations of array elements. need volunteer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-29 08:43:59 +00:00
nobu
c351afc372
* encoding.c (rb_enc_alias): allow encodings multiple aliases.
...
* encoding.c (rb_enc_find_index): search the encoding which has the
given name and return its index if found, or -1.
* st.c (type_strcasehash): case-insensitive string hash type.
* string.c (rb_str_force_encoding): force encoding of self. this name
comes from [ruby-dev:31894] by Martin Duerst. [ruby-dev:31744]
* include/ruby/encoding.h (rb_enc_find_index, rb_enc_associate_index):
prototyped.
* include/ruby/encoding.h (rb_enc_isctype): direct interface to ctype.
* include/ruby/st.h (st_init_strcasetable): prototyped.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 19:27:10 +00:00
matz
335fe1ee7b
* string.c (rb_str_comparable): need not to check asciicompat here.
...
* encoding.c (rb_enc_check): ditto.
* string.c (rb_enc_str_coderange): tuned a bit; no broken check.
* encoding.c (rb_enc_check): new encoding comparison criteria.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 09:07:02 +00:00
nobu
19d8793ef4
* string.c (rb_str_associate_encoding): commit miss.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 19:51:00 +00:00
nobu
e41b84895e
* encoding.c (rb_enc_associate_index): deal with ASCII compatible
...
flags.
* encoding.c (rb_enc_check): allow ASCII compatible strings.
* parse.y (rb_intern_str): use ASCII encoding for ASCII string.
* string.c (rb_enc_str_coderange): check for code-range.
* string.c (rb_str_modify): clear code-range flags.
* string.c (rb_str_hash, rb_str_eql): ASCII compatible strings are
comparable.
* include/ruby/encoding.h: added code-range flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 19:46:58 +00:00
nobu
94a0db11e7
* encoding.c (rb_enc_check): check for ASCII-compatibilities.
...
* parse.y (parser_tokadd_string, parser_parse_string,
parser_here_document, parser_yylex): set encoding to US-ASCII.
* parse.y (rb_enc_symname_p): check if valid with encoding.
* parse.y (rb_intern3): let symbols have encoding.
* string.c (rb_str_hash): add encoding index.
* string.c (rb_str_comparable, rb_str_equal, rb_str_eql): check if
compatible encoding.
* string.c (sym_inspect): made encoding aware.
* insns.def (opt_eq): compare with encoding.
* include/ruby/encoding.h (rb_enc_asciicompat): check if ASCII
compatible.
* include/ruby/encoding.h (rb_enc_get_index): added prototype.
* include/ruby/intern.h (rb_str_comparable, rb_str_equal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 09:39:08 +00:00
matz
5376745fb6
* re.c (rb_reg_match_m): evaluate a block if match. it would make
...
condition statement much shorter, if no else clause is needed.
* string.c (rb_str_match_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 17:14:01 +00:00
kou
740e1b66c8
* string.c (rb_str_rstrip_bang): fixed too much rstrip. [ruby-dev:31786]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-15 09:26:06 +00:00
nobu
26adfc185f
* encoding.c (rb_enc_associate_index, rb_enc_get_index): check if
...
object is encoding capable. [ruby-dev:31780]
* string.c (rb_str_subpat_set): check for if the argument is a String.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-15 08:04:10 +00:00
matz
edd7c787ad
* array.c (rb_ary_cycle): typo in rdoc. a patch from Yugui
...
<yugui@yugui.sakura.ne.jp>. [ruby-dev:31748]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 12:33:45 +00:00
nobu
629b1e4324
* string.c (rb_str_succ, rb_str_chop_bang, rb_str_chop): m17n support.
...
[ruby-dev:31734]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 03:42:12 +00:00
matz
c349959778
* string.c (rb_str_splice): integer overflow for length.
...
[ruby-dev:31739]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:06:01 +00:00
nobu
b58f080349
* string.c (tr_trans, rb_str_squeeze_bang, rb_str_split_m): suppress
...
warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-30 02:44:20 +00:00
matz
3d7f8c2320
* string.c (str_gsub): should not use mbclen2() which has broken API.
...
* re.c: remove rb_reg_mbclen2().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-29 19:16:02 +00:00
matz
51b4cc11d1
* string.c (rb_str_subseq): retrieve substring based on byte offset.
...
* string.c (rb_str_rindex_m): was confusing character offset and
byte offset.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-28 06:45:32 +00:00
nobu
53635dea12
* string.c (rb_str_splice_0): should check to modify. [ruby-dev:31665]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-28 05:23:33 +00:00
matz
51fb5511e0
* string.c (rb_str_each_line): should swallow sequence of newlines
...
if rs (optional argument) is an empty string. [ruby-dev:31652]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 14:32:15 +00:00
matz
9166bd2bc9
* string.c (rb_str_rstrip_bang): wrong strip point. [ruby-dev:31652]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 14:17:28 +00:00
nobu
3ca07d8718
* string.c (sym_encoding): return the encoding of a Symbol.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 06:56:49 +00:00
matz
fa02a6cedd
* string.c (tr_trans): wrong condition for mbmaxlen==1 strings.
...
[ruby-dev:31652]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 04:51:45 +00:00
ko1
5ba27573a0
* string.c, include/ruby/intern.h: export rb_str_length().
...
* insns.def: use rb_str_lengt() in opt_length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 08:54:29 +00:00
nobu
10f56f8fd0
* string.c (rb_str_splice): return from void funtion.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 07:14:01 +00:00
matz
a25fbe3b3e
* encoding.c: provide basic features for M17N.
...
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
matz
5e1c401ff5
* array.c (rb_ary_s_try_convert): a new class method to convert
...
object or nil if it's not target-type. this mechanism is used
to convert types in the C implemented methods.
* hash.c (rb_hash_s_try_convert): ditto.
* io.c (rb_io_s_try_convert): ditto.
* re.c (rb_reg_s_try_convert): ditto.
* string.c (rb_str_s_try_convert): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 17:47:09 +00:00
matz
b6449f6080
* string.c (Init_String): remove Symbol.intern and Symbol#dump.
...
[ruby-dev:31525]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-20 14:30:12 +00:00
nobu
c2a41b3a71
* insnhelper.ci, string.c: fixed indent.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-18 05:11:49 +00:00
nobu
4b40f2c516
* string.c (rb_str_resize): fix indent.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-21 14:54:51 +00:00
nobu
6c12b69fda
* string.c (rb_str_rindex_m): accept string-like object convertible
...
with #to_str method, as well as rb_str_index_m. [ruby-core:11692]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-16 09:29:35 +00:00
matz
99c58e9ebc
* string.c (rb_str_clear): need to check STR_EMBED_P() before
...
free()ing memory. a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
[ruby-dev:31062]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-26 15:19:39 +00:00
akr
fe377d3b8e
update document to follow MatchData#inspect implementation.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-23 08:34:21 +00:00
matz
115410ecde
* string.c (rb_str_upto): add optional argument to specify
...
exclusiveness.
* range.c (range_step): use String#upto with optional argument.
* range.c (range_each): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-22 16:23:16 +00:00
nobu
2b592580bf
* include/ruby: moved public headers.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00