summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-12 15:44:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-12 15:44:24 +0000
commit0884036a0a9d93bb4c3f82f56f997f32557d8159 (patch)
treeb7c728d560098689bfa0c56a06c1eb6bac430260 /file.c
parentfbdabf398f397c7c68434b26556e4890133d70c4 (diff)
* file.c (rb_file_s_basename): check encoding of suffix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/file.c b/file.c
index 50516ad4f8..4e0a0f13e4 100644
--- a/file.c
+++ b/file.c
@@ -3324,9 +3324,15 @@ rb_file_s_basename(int argc, VALUE *argv)
long f, n;
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
+ rb_encoding *enc;
StringValue(fext);
+ if (!rb_enc_asciicompat(enc = rb_enc_get(fext))) {
+ rb_raise(rb_eEncCompatError, "ascii incompatible character encodings: %s",
+ rb_enc_name(enc));
+ }
}
FilePathStringValue(fname);
+ if (!NIL_P(fext)) rb_enc_check(fname, fext);
if (RSTRING_LEN(fname) == 0 || !*(name = RSTRING_PTR(fname)))
return rb_str_new_shared(fname);
name = skipprefix(name);