[macruby-changes] [4982] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Sun Dec 5 17:35:02 PST 2010
Revision: 4982
http://trac.macosforge.org/projects/ruby/changeset/4982
Author: lsansonetti at apple.com
Date: 2010-12-05 17:34:59 -0800 (Sun, 05 Dec 2010)
Log Message:
-----------
ascii-only strings are now compatible with any other string (patch by Vincent Isambart)
Modified Paths:
--------------
MacRuby/trunk/string.c
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-12-05 09:21:16 UTC (rev 4981)
+++ MacRuby/trunk/string.c 2010-12-06 01:34:59 UTC (rev 4982)
@@ -181,6 +181,9 @@
if (str_is_ruby_ascii_only(str2)) {
return str1->encoding;
}
+ if (str_is_ruby_ascii_only(str1)) {
+ return str2->encoding;
+ }
return NULL;
}
@@ -863,7 +866,7 @@
return;
}
- str_must_have_compatible_encoding(self, str);
+ rb_encoding_t *enc = str_must_have_compatible_encoding(self, str);
str_make_same_format(self, str);
// TODO: we should maybe merge flags
@@ -872,6 +875,8 @@
str_unset_facultative_flags(self);
str_concat_bytes(self, str->data.bytes, str->length_in_bytes);
+
+ self->encoding = enc;
}
static int
@@ -2369,15 +2374,6 @@
{
rb_str_t *newstr = str_dup(RSTR(self));
rb_str_t *otherstr = str_need_string(other);
- // if other cannot be concatenated to self
- // but self is ASCII-only and the encodings of both string are ASCII-compatible
- // then the new string takes the encoding of other
- if ((str_compatible_encoding(newstr, otherstr) == NULL)
- && newstr->encoding->ascii_compatible
- && otherstr->encoding->ascii_compatible
- && str_is_ruby_ascii_only(newstr)) {
- newstr->encoding = otherstr->encoding;
- }
str_concat_string(newstr, otherstr);
if (OBJ_TAINTED(self) || OBJ_TAINTED(other)) {
OBJ_TAINT(newstr);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101205/863ce4f0/attachment.html>
More information about the macruby-changes
mailing list