file.c: normalize Form C
* file.c (rb_str_normalize_ospath): normalize to Normalization Form C using CFString. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f9cbf0e89f
commit
c04f402f0f
@ -1,3 +1,8 @@
|
|||||||
|
Fri Aug 9 12:06:49 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_str_normalize_ospath): normalize to Normalization Form C
|
||||||
|
using CFString.
|
||||||
|
|
||||||
Fri Aug 9 10:53:57 2013 Kazuki Tsujimoto <kazuki@callcc.net>
|
Fri Aug 9 10:53:57 2013 Kazuki Tsujimoto <kazuki@callcc.net>
|
||||||
|
|
||||||
* time.c (get_timeval, get_new_timeval): use rb_obj_class()
|
* time.c (get_timeval, get_new_timeval): use rb_obj_class()
|
||||||
|
@ -3061,6 +3061,8 @@ AS_CASE("$enable_shared", [yes], [
|
|||||||
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "' $(XLDFLAGS)'
|
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "' $(XLDFLAGS)'
|
||||||
LIBRUBY_SO='lib$(RUBY_SO_NAME).dylib'
|
LIBRUBY_SO='lib$(RUBY_SO_NAME).dylib'
|
||||||
LIBRUBY_ALIASES='lib$(RUBY_BASE_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib'
|
LIBRUBY_ALIASES='lib$(RUBY_BASE_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib'
|
||||||
|
RUBY_APPEND_OPTION(XLDFLAGS, [-framework CoreFoundation])
|
||||||
|
RUBY_APPEND_OPTION(LIBRUBYARG_STATIC, [-framework CoreFoundation])
|
||||||
],
|
],
|
||||||
[interix*], [
|
[interix*], [
|
||||||
LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
|
LIBRUBYARG_SHARED='-L. -L${libdir} -l$(RUBY_SO_NAME)'
|
||||||
|
28
file.c
28
file.c
@ -19,6 +19,9 @@
|
|||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <CoreFoundation/CFString.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "ruby/io.h"
|
#include "ruby/io.h"
|
||||||
@ -244,12 +247,25 @@ rb_str_encode_ospath(VALUE path)
|
|||||||
VALUE
|
VALUE
|
||||||
rb_str_normalize_ospath(const char *ptr, long len)
|
rb_str_normalize_ospath(const char *ptr, long len)
|
||||||
{
|
{
|
||||||
rb_encoding *utf8mac = rb_enc_from_index(ENCINDEX_UTF8_MAC);
|
VALUE str;
|
||||||
if (utf8mac) {
|
CFIndex buflen = 0;
|
||||||
return rb_str_conv_enc(rb_tainted_str_new(ptr, len),
|
CFRange all;
|
||||||
utf8mac, rb_utf8_encoding());
|
CFStringRef s = CFStringCreateWithBytesNoCopy(kCFAllocatorDefault,
|
||||||
}
|
(const UInt8 *)ptr, len,
|
||||||
return Qnil;
|
kCFStringEncodingUTF8, FALSE,
|
||||||
|
kCFAllocatorNull);
|
||||||
|
CFMutableStringRef m = CFStringCreateMutableCopy(kCFAllocatorDefault, len, s);
|
||||||
|
|
||||||
|
CFStringNormalize(m, kCFStringNormalizationFormC);
|
||||||
|
all = CFRangeMake(0, CFStringGetLength(m));
|
||||||
|
CFStringGetBytes(m, all, kCFStringEncodingUTF8, '?', FALSE, NULL, 0, &buflen);
|
||||||
|
str = rb_enc_str_new(0, buflen, rb_utf8_encoding());
|
||||||
|
CFStringGetBytes(m, all, kCFStringEncodingUTF8, '?', FALSE, (UInt8 *)RSTRING_PTR(str),
|
||||||
|
buflen, &buflen);
|
||||||
|
rb_str_set_len(str, buflen);
|
||||||
|
CFRelease(m);
|
||||||
|
CFRelease(s);
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -237,6 +237,8 @@ class TestProcess < Test::Unit::TestCase
|
|||||||
MANDATORY_ENVS << 'LD_PRELOAD'
|
MANDATORY_ENVS << 'LD_PRELOAD'
|
||||||
when /mswin|mingw/
|
when /mswin|mingw/
|
||||||
MANDATORY_ENVS.concat(%w[HOME USER TMPDIR])
|
MANDATORY_ENVS.concat(%w[HOME USER TMPDIR])
|
||||||
|
when /darwin/
|
||||||
|
MANDATORY_ENVS.concat(ENV.keys.grep(/\A__CF_/))
|
||||||
end
|
end
|
||||||
if e = RbConfig::CONFIG['LIBPATHENV']
|
if e = RbConfig::CONFIG['LIBPATHENV']
|
||||||
MANDATORY_ENVS << e
|
MANDATORY_ENVS << e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user