aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-15 05:04:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-15 05:04:36 +0000
commit6951fbca430cc707bfaeeab3fffa4aebbc646ef9 (patch)
treedc2f2367dadd1bc0661d5d9e28e3df5f4ac7cf35 /string.c
parent77ae7b2e8353c963404c31c6d910fe77286cbd81 (diff)
downloadruby-6951fbca430cc707bfaeeab3fffa4aebbc646ef9.tar.gz
string.c: respect BOM
* string.c (get_encoding): respect BOM on pseudo encodings. [ruby-dev:47895] [Bug #9415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/string.c b/string.c
index 50b050bb5d..ee57f92716 100644
--- a/string.c
+++ b/string.c
@@ -121,7 +121,7 @@ VALUE rb_cSymbol;
#define STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr)
#define STR_HEAP_SIZE(str) (RSTRING(str)->as.heap.aux.capa + TERM_LEN(str))
-#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
+#define STR_ENC_GET(str) get_encoding(str)
rb_encoding *rb_enc_get_from_index(int index);
@@ -155,6 +155,12 @@ get_actual_encoding(const int encidx, VALUE str)
return rb_enc_from_index(encidx);
}
+static rb_encoding *
+get_encoding(VALUE str)
+{
+ return get_actual_encoding(ENCODING_GET(str), str);
+}
+
static int fstring_cmp(VALUE a, VALUE b);
static st_table* frozen_strings;