Permalink
Browse files

Declaring diff_CFStringCreate…() utility functions CF_INLINE and movi…

…ng them to “DiffMatchPatchCFUtilities.h”.
  • Loading branch information...
1 parent c89be3a commit 287b0e41af62bc99b3b46e2dc35ea84dc46fe5f8 @JanX2 committed May 28, 2012
Showing with 27 additions and 56 deletions.
  1. +0 −55 DiffMatchPatchCFUtilities.c
  2. +27 −1 DiffMatchPatchCFUtilities.h
@@ -29,14 +29,6 @@
#include <limits.h>
#include <AssertMacros.h>
-#if ENABLE_UNUSED_CODE
-CFRange diff_RightSubstringRange(CFIndex text_length, CFIndex new_length);
-CFRange diff_LeftSubstringRange(CFIndex new_length);
-#endif
-CFStringRef diff_CFStringCreateRightSubstring(CFStringRef text, CFIndex text_length, CFIndex new_length);
-CFStringRef diff_CFStringCreateLeftSubstring(CFStringRef text, CFIndex new_length);
-CFStringRef diff_CFStringCreateSubstringWithStartIndex(CFStringRef text, CFIndex start_index);
-CFStringRef diff_CFStringCreateJavaSubstring(CFStringRef s, CFIndex begin, CFIndex end);
Boolean diff_regExMatch(CFStringRef text, const regex_t *re);
CFArrayRef diff_halfMatchICreate(CFStringRef longtext, CFStringRef shorttext, CFIndex i);
@@ -49,53 +41,6 @@ CFStringRef diff_CFStringCreateFromUnichar(UniChar ch) {
return c;
}
-CF_INLINE CFStringRef diff_CFStringCreateSubstring(CFStringRef text, CFIndex start_index, CFIndex length) {
- CFRange substringRange = {
- .length = length,
- .location = start_index,
- };
-
- CFStringRef substring = CFStringCreateWithSubstring(kCFAllocatorDefault, text, substringRange);
-
- return substring;
-}
-
-#if ENABLE_UNUSED_CODE
-CFRange diff_RightSubstringRange(CFIndex text_length, CFIndex new_length) {
- CFRange substringRange = {
- .length = new_length,
- .location = text_length - new_length,
- };
- return substringRange;
-}
-#endif
-
-CFStringRef diff_CFStringCreateRightSubstring(CFStringRef text, CFIndex text_length, CFIndex new_length) {
- return diff_CFStringCreateSubstring(text, text_length - new_length, new_length);
-}
-
-#if ENABLE_UNUSED_CODE
-CFRange diff_LeftSubstringRange(CFIndex new_length) {
- CFRange substringRange = {
- .length = new_length,
- .location = 0,
- };
- return substringRange;
-}
-#endif
-
-CFStringRef diff_CFStringCreateLeftSubstring(CFStringRef text, CFIndex new_length) {
- return diff_CFStringCreateSubstring(text, 0, new_length);
-}
-
-CFStringRef diff_CFStringCreateSubstringWithStartIndex(CFStringRef text, CFIndex start_index) {
- return diff_CFStringCreateSubstring(text, start_index, (CFStringGetLength(text) - start_index));
-}
-
-CFStringRef diff_CFStringCreateJavaSubstring(CFStringRef s, CFIndex begin, CFIndex end) {
- return diff_CFStringCreateSubstring(s, begin, end - begin);
-}
-
Boolean diff_regExMatch(CFStringRef text, const regex_t *re) {
//TODO(jan): Using regex.h is far from optimal. Find an alternative.
Boolean isMatch;
@@ -24,7 +24,33 @@
#define _DIFFMATCHPATCHCFUTILITIES_H
CFStringRef diff_CFStringCreateFromUnichar(UniChar ch);
-CFStringRef diff_CFStringCreateJavaSubstring(CFStringRef s, CFIndex begin, CFIndex end);
+
+CF_INLINE CFStringRef diff_CFStringCreateSubstring(CFStringRef text, CFIndex start_index, CFIndex length) {
+ CFRange substringRange = {
+ .length = length,
+ .location = start_index,
+ };
+
+ CFStringRef substring = CFStringCreateWithSubstring(kCFAllocatorDefault, text, substringRange);
+
+ return substring;
+}
+
+CF_INLINE CFStringRef diff_CFStringCreateRightSubstring(CFStringRef text, CFIndex text_length, CFIndex new_length) {
+ return diff_CFStringCreateSubstring(text, text_length - new_length, new_length);
+}
+
+CF_INLINE CFStringRef diff_CFStringCreateLeftSubstring(CFStringRef text, CFIndex new_length) {
+ return diff_CFStringCreateSubstring(text, 0, new_length);
+}
+
+CF_INLINE CFStringRef diff_CFStringCreateSubstringWithStartIndex(CFStringRef text, CFIndex start_index) {
+ return diff_CFStringCreateSubstring(text, start_index, (CFStringGetLength(text) - start_index));
+}
+
+CF_INLINE CFStringRef diff_CFStringCreateJavaSubstring(CFStringRef s, CFIndex begin, CFIndex end) {
+ return diff_CFStringCreateSubstring(s, begin, end - begin);
+}
CFIndex diff_commonPrefix(CFStringRef text1, CFStringRef text2);
CFIndex diff_commonSuffix(CFStringRef text1, CFStringRef text2);

0 comments on commit 287b0e4

Please sign in to comment.