Permalink
Browse files

More normalization of filenames, use NFC

Apparently NTFS uses NFC so switch to NFC instead of using NFKC.
  • Loading branch information...
1 parent 0d778b2 commit 36154dd8c0ed935a736d4f810e9d41f68e068453 @b4winckler committed Jul 10, 2009
Showing with 23 additions and 13 deletions.
  1. +0 −2 src/MacVim/MMAppController.m
  2. +8 −4 src/MacVim/MMVimController.m
  3. +8 −5 src/MacVim/Miscellaneous.h
  4. +7 −2 src/MacVim/Miscellaneous.m
View
2 src/MacVim/MMAppController.m
@@ -836,8 +836,6 @@ - (BOOL)openFiles:(NSArray *)filenames withArguments:(NSDictionary *)args
NSMutableDictionary *arguments = (args ? [[args mutableCopy] autorelease]
: [NSMutableDictionary dictionary]);
- // Filenames on HFS+ are in NFD but Vim does not handle this form very well
- // so normalize to NFKC first.
filenames = normalizeFilenames(filenames);
//
View
12 src/MacVim/MMVimController.m
@@ -252,6 +252,7 @@ - (int)pid
- (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force
{
+ filenames = normalizeFilenames(filenames);
ASLogInfo(@"filenames=%@ force=%d", filenames, force);
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
@@ -265,10 +266,6 @@ - (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force
if (splitVert && MMLayoutHorizontalSplit == layout)
layout = MMLayoutVerticalSplit;
- // Filenames on HFS+ are in NFD but Vim does not handle this form very well
- // so normalize to NFKC first.
- filenames = normalizeFilenames(filenames);
-
NSDictionary *args = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:layout], @"layout",
filenames, @"filenames",
@@ -280,6 +277,9 @@ - (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force
- (void)file:(NSString *)filename draggedToTabAtIndex:(NSUInteger)tabIndex
{
+ filename = normalizeFilename(filename);
+ ASLogInfo(@"filename=%@ index=%d", filename, tabIndex);
+
NSString *fnEsc = [filename stringByEscapingSpecialFilenameCharacters];
NSString *input = [NSString stringWithFormat:@"<C-\\><C-N>:silent "
"tabnext %d |"
@@ -289,6 +289,9 @@ - (void)file:(NSString *)filename draggedToTabAtIndex:(NSUInteger)tabIndex
- (void)filesDraggedToTabBar:(NSArray *)filenames
{
+ filenames = normalizeFilenames(filenames);
+ ASLogInfo(@"%@", filenames);
+
NSUInteger i, count = [filenames count];
NSMutableString *input = [NSMutableString stringWithString:@"<C-\\><C-N>"
":silent! tabnext 9999"];
@@ -303,6 +306,7 @@ - (void)filesDraggedToTabBar:(NSArray *)filenames
- (void)dropString:(NSString *)string
{
+ ASLogInfo(@"%@", string);
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1;
if (len > 0) {
NSMutableData *data = [NSMutableData data];
View
13 src/MacVim/Miscellaneous.h
@@ -128,9 +128,12 @@ enum {
NSView *showHiddenFilesView();
-// Convert filenames (which are in decomposed form, NFD, on HFS+) to
-// normalization form combatibility C (NFKC). (This is necessary because Vim
-// does not automatically compose NFD. We choose NFKC instead of NFC for the
-// somewhat random reason that this is what is used on Windows and hence
-// hopefully Vim is better prepared for it.)
+// Convert filenames (which are in a variant of decomposed form, NFD, on HFS+)
+// to normalization form C (NFC). (This is necessary because Vim does not
+// automatically compose NFD.) For more information see:
+// http://developer.apple.com/technotes/tn/tn1150.html
+// http://developer.apple.com/technotes/tn/tn1150table.html
+// http://developer.apple.com/qa/qa2001/qa1235.html
+// http://www.unicode.org/reports/tr15/
+NSString *normalizeFilename(NSString *filename);
NSArray *normalizeFilenames(NSArray *filenames);
View
9 src/MacVim/Miscellaneous.m
@@ -294,6 +294,12 @@ - (int)tag
+ NSString *
+normalizeFilename(NSString *filename)
+{
+ return [filename precomposedStringWithCanonicalMapping];
+}
+
NSArray *
normalizeFilenames(NSArray *filenames)
{
@@ -303,8 +309,7 @@ - (int)tag
unsigned i, count = [filenames count];
for (i = 0; i < count; ++i) {
- NSString *nfkc = [filenames objectAtIndex:i];
- nfkc = [nfkc precomposedStringWithCompatibilityMapping];
+ NSString *nfkc = normalizeFilename([filenames objectAtIndex:i]);
[outnames addObject:nfkc];
}

0 comments on commit 36154dd

Please sign in to comment.