[macruby-changes] [4991] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 7 00:48:03 PST 2010
Revision: 4991
http://trac.macosforge.org/projects/ruby/changeset/4991
Author: lsansonetti at apple.com
Date: 2010-12-07 00:47:56 -0800 (Tue, 07 Dec 2010)
Log Message:
-----------
Dir.glob: convert paths to unicode normalization form C
Modified Paths:
--------------
MacRuby/trunk/dir.c
MacRuby/trunk/encoding.h
MacRuby/trunk/string.c
Modified: MacRuby/trunk/dir.c
===================================================================
--- MacRuby/trunk/dir.c 2010-12-07 08:15:19 UTC (rev 4990)
+++ MacRuby/trunk/dir.c 2010-12-07 08:47:56 UTC (rev 4991)
@@ -15,6 +15,7 @@
#include "ruby/node.h"
#include "ruby/util.h"
#include "vm.h"
+#include "encoding.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1391,7 +1392,9 @@
static void
push_pattern(const char *path, VALUE ary)
{
- rb_ary_push(ary, rb_tainted_str_new2(path));
+ VALUE str = rstr_new_path(path);
+ OBJ_TAINT(str);
+ rb_ary_push(ary, str);
}
int
Modified: MacRuby/trunk/encoding.h
===================================================================
--- MacRuby/trunk/encoding.h 2010-12-07 08:15:19 UTC (rev 4990)
+++ MacRuby/trunk/encoding.h 2010-12-07 08:47:56 UTC (rev 4991)
@@ -368,6 +368,8 @@
}
}
+VALUE rstr_new_path(const char *path);
+
#if defined(__cplusplus)
} // extern "C"
#endif
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-12-07 08:15:19 UTC (rev 4990)
+++ MacRuby/trunk/string.c 2010-12-07 08:47:56 UTC (rev 4991)
@@ -6724,3 +6724,22 @@
rb_raise(rb_eArgError, "can't modify NSString");
}
}
+
+VALUE
+rstr_new_path(const char *path)
+{
+ // XXX this should be rewritten using ICU (utrans.h?) to avoid creating
+ // these 2 temporary CFStrings.
+ CFStringRef tmp = CFStringCreateWithFileSystemRepresentation(NULL, path);
+ assert(tmp != NULL);
+
+ CFMutableStringRef tmp2 = CFStringCreateMutableCopy(NULL, 0, tmp);
+ assert(tmp2 != NULL);
+ CFRelease(tmp);
+ CFStringNormalize(tmp2, kCFStringNormalizationFormC);
+
+ rb_str_t *str = str_new_from_cfstring(tmp2);
+ CFRelease(tmp2);
+
+ return (VALUE)str;
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101207/1e8be11b/attachment.html>
More information about the macruby-changes
mailing list