Permalink
Browse files

Fixing symbol names and options to correctly represent what “line bre…

…ak mode” actually does.
  • Loading branch information...
1 parent 7102b74 commit 81921bcf4f691ec68758db35b27bd4a0bfc12495 @JanX2 committed Jun 10, 2011
Showing with 23 additions and 21 deletions.
  1. +2 −2 DiffMatchPatch.h
  2. +10 −9 DiffMatchPatch.m
  3. +4 −3 DiffMatchPatchCFUtilities.c
  4. +1 −1 DiffMatchPatchCFUtilities.h
  5. +6 −6 Tests/mode-test.m
View
@@ -46,7 +46,7 @@ typedef enum {
DiffWordTokens = 1,
DiffParagraphTokens = 2,
DiffSentenceTokens = 3,
- DiffLineBreakAgnosticLineTokens = 4
+ DiffLineBreakDelimiteredTokens = 4
} DiffTokenMode;
/*
@@ -170,7 +170,7 @@ typedef enum {
- (NSString *)diff_wordsToCharsMungeOfText:(NSString *)text wordArray:(NSMutableArray *)wordArray wordHash:(NSMutableDictionary *)wordHash;
- (NSString *)diff_sentencesToCharsMungeOfText:(NSString *)text sentenceArray:(NSMutableArray *)sentenceArray sentenceHash:(NSMutableDictionary *)sentenceHash;
- (NSString *)diff_paragraphsToCharsMungeOfText:(NSString *)text paragraphArray:(NSMutableArray *)paragraphArray paragraphHash:(NSMutableDictionary *)paragraphHash;
-- (NSString *)diff_lineBreakAgnosticLinesToCharsMungeOfText:(NSString *)text lineArray:(NSMutableArray *)lineArray lineHash:(NSMutableDictionary *)lineHash;
+- (NSString *)diff_lineBreakDelimiteredToCharsMungeOfText:(NSString *)text lineArray:(NSMutableArray *)lineArray lineHash:(NSMutableDictionary *)lineHash;
- (void)diff_chars:(NSArray *)diffs toLines:(NSMutableArray *)lineArray;
- (NSMutableArray *)diff_bisectOfOldString:(NSString *)text1 andNewString:(NSString *)text2 deadline:(NSTimeInterval)deadline;
- (NSMutableArray *)diff_bisectSplitOfOldString:(NSString *)text1 andNewString:(NSString *)text2 x:(NSUInteger)x y:(NSUInteger)y deadline:(NSTimeInterval)deadline;
View
@@ -696,20 +696,21 @@ - (NSString *)diff_paragraphsToCharsMungeOfText:(NSString *)text
/**
* Split a text into a list of strings. Reduce the texts to a string of
- * hashes where each Unicode character represents one line.
- * This is a line break agnostic version: it does not care which type of line break is used.
+ * hashes where each Unicode character represents one text fragment delimitered by line breaks (including the trailing line break characters if any).
+ * In this context “line break” does not refere to “something you get when you press the return-key”.
+ * Instead it the refers to “line break boundaries” as defined in “UAX #14: Unicode Line Breaking Algorithm” (http://www.unicode.org/reports/tr14/).
* @param text NSString to encode.
* @param lineArray NSMutableArray of unique strings.
* @param lineHash Map of strings to indices.
* @return Encoded string.
*/
-- (NSString *)diff_lineBreakAgnosticLinesToCharsMungeOfText:(NSString *)text
- lineArray:(NSMutableArray *)lineArray
- lineHash:(NSMutableDictionary *)lineHash;
+- (NSString *)diff_lineBreakDelimiteredToCharsMungeOfText:(NSString *)text
+ lineArray:(NSMutableArray *)lineArray
+ lineHash:(NSMutableDictionary *)lineHash;
{
- return [NSMakeCollectable(diff_lineBreakAgnosticLinesToCharsMungeCFStringCreate((CFStringRef)text,
- (CFMutableArrayRef)lineArray,
- (CFMutableDictionaryRef)lineHash)) autorelease];
+ return [NSMakeCollectable(diff_lineBreakDelimiteredToCharsMungeCFStringCreate((CFStringRef)text,
+ (CFMutableArrayRef)lineArray,
+ (CFMutableDictionaryRef)lineHash)) autorelease];
}
/**
@@ -976,7 +977,7 @@ - (NSArray *)diff_tokensToCharsForFirstString:(NSString *)text1
case DiffSentenceTokens:
tokenizerOptions = kCFStringTokenizerUnitSentence;
break;
- case DiffLineBreakAgnosticLineTokens:
+ case DiffLineBreakDelimiteredTokens:
default:
tokenizerOptions = kCFStringTokenizerUnitLineBreak;
break;
@@ -599,14 +599,15 @@ CFStringRef diff_paragraphsToCharsMungeCFStringCreate(CFStringRef text, CFMutabl
/**
* Split a text into a list of strings. Reduce the texts to a CFStringRef of
- * hashes where where each Unicode character represents one line.
- * This is a line break agnostic version: it does not care which type of line break is used.
+ * hashes where each Unicode character represents one text fragment delimitered by line breaks (including the trailing line break characters if any).
+ * In this context “line break” does not refere to “something you get when you press the return-key”.
+ * Instead it the refers to “line break boundaries” as defined in “UAX #14: Unicode Line Breaking Algorithm” (http://www.unicode.org/reports/tr14/).
* @param text CFString to encode.
* @param lineArray CFMutableArray of unique strings.
* @param lineHash Map of strings to indices.
* @return Encoded CFStringRef.
*/
-CFStringRef diff_lineBreakAgnosticLinesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash) {
+CFStringRef diff_lineBreakDelimiteredToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash) {
return diff_tokensToCharsMungeCFStringCreate(text, tokenArray, tokenHash, kCFStringTokenizerUnitLineBreak);
@@ -37,7 +37,7 @@ CFStringRef diff_tokensToCharsMungeCFStringCreate(CFStringRef text, CFMutableArr
CFStringRef diff_wordsToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
CFStringRef diff_sentencesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
CFStringRef diff_paragraphsToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
-CFStringRef diff_lineBreakAgnosticLinesToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
+CFStringRef diff_lineBreakDelimiteredToCharsMungeCFStringCreate(CFStringRef text, CFMutableArrayRef tokenArray, CFMutableDictionaryRef tokenHash);
CFIndex diff_cleanupSemanticScore(CFStringRef one, CFStringRef two);
View
@@ -31,7 +31,7 @@
DiffWordMode = 3,
DiffParagraphMode = 4,
DiffSentenceMode = 5,
- DiffLineBreakAgnosticLineMode = 6
+ DiffLineBreakDelimiteredMode = 6
} DiffMode;
@@ -61,8 +61,8 @@
case DiffSentenceMode:
tokenMode = DiffSentenceTokens;
break;
- case DiffLineBreakAgnosticLineMode:
- tokenMode = DiffLineBreakAgnosticLineTokens;
+ case DiffLineBreakDelimiteredMode:
+ tokenMode = DiffLineBreakDelimiteredTokens;
break;
default:
tokenMode = 0;
@@ -132,7 +132,7 @@ int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if ([[[NSProcessInfo processInfo] arguments] count] < 3) {
- fprintf(stderr, "usage: %s <txt1> <txt2> [default|line|word|paragraph|sentence|line-break-agnostic]\n",
+ fprintf(stderr, "usage: %s <txt1> <txt2> [default|line|word|paragraph|sentence|line-break-delimitered]\n",
[[[NSProcessInfo processInfo] processName] UTF8String]);
[pool drain];
return EXIT_FAILURE;
@@ -169,8 +169,8 @@ int main (int argc, const char * argv[]) {
else if ([modeString isEqualToString:@"sentence"]) {
mode = DiffSentenceMode;
}
- else if ([modeString isEqualToString:@"line-break-agnostic"]) {
- mode = DiffLineBreakAgnosticLineMode;
+ else if ([modeString isEqualToString:@"line-break-delimitered"]) {
+ mode = DiffLineBreakDelimiteredMode;
}
}

0 comments on commit 81921bc

Please sign in to comment.