Revision: 3201
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3201&view=rev
Author:   hofman
Date:     2007-11-12 14:55:26 -0800 (Mon, 12 Nov 2007)

Log Message:
-----------
Ignore hyphenation when cleaning selection string.

Modified Paths:
--------------
    trunk/NSString_SKExtensions.m

Modified: trunk/NSString_SKExtensions.m
===================================================================
--- trunk/NSString_SKExtensions.m       2007-11-12 21:15:41 UTC (rev 3200)
+++ trunk/NSString_SKExtensions.m       2007-11-12 22:55:26 UTC (rev 3201)
@@ -75,16 +75,21 @@
     
     NSCAssert1(buffer != NULL, @"failed to allocate memory for string of 
length %d", length);
     
-    BOOL isFirst = NO;
+    BOOL isFirst = NO, wasHyphen = NO;
     int bufCnt = 0;
     for(cnt = 0; cnt < length; cnt++){
         ch = CFStringGetCharacterFromInlineBuffer(&inlineBuffer, cnt);
         if(NO == 
CFCharacterSetIsCharacterMember(CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline),
 ch)){
+            wasHyphen = (ch == '-');
             isFirst = YES;
             buffer[bufCnt++] = ch; // not whitespace, so we want to keep it
         } else {
             if(isFirst){
-                buffer[bufCnt++] = ' '; // if it's the first whitespace, we 
add a single space
+                if(wasHyphen && 
CFCharacterSetIsCharacterMember((CFCharacterSetRef)[NSCharacterSet 
newlineCharacterSet], ch))
+                    bufCnt--; // ignore the last hyphen and current newline
+                else
+                    buffer[bufCnt++] = ' '; // if it's the first whitespace, 
we add a single space
+                wasHyphen = NO;
                 isFirst = NO;
             }
         }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to