adium 3177:7aafecd5cd6e: Replace AH with AH2 from http://bitbuck...

commits at adium.im commits at adium.im
Wed Apr 28 03:33:24 UTC 2010


details:	http://hg.adium.im/adium/rev/7aafecd5cd6e
revision:	3177:7aafecd5cd6e
author:		Stephen Holt <sholt at adium.im>
date:		Tue Apr 27 20:19:07 2010 -0700

Replace AH with AH2 from http://bitbucket.org/sholt/autohyperlinks2/

Mostly, this has a small list of precompiled URI schemes.  For any scheme not in that list we ask LaunchServices if the system has an app that can handle it.  If it does, we link.
Subject: adium 3178:f824040fadf2: Tell AH2 to build into the right dir.

details:	http://hg.adium.im/adium/rev/f824040fadf2
revision:	3178:f824040fadf2
author:		Stephen Holt <sholt at adium.im>
date:		Tue Apr 27 20:23:40 2010 -0700

Tell AH2 to build into the right dir.
Subject: adium 3179:f3768d0d65a2: Add schemeLength parameter to isStringValidURI... method calls.

details:	http://hg.adium.im/adium/rev/f3768d0d65a2
revision:	3179:f3768d0d65a2
author:		Stephen Holt <sholt at adium.im>
date:		Tue Apr 27 20:31:08 2010 -0700

Add schemeLength parameter to isStringValidURI... method calls.

diffs (truncated from 1907 to 1000 lines):

diff -r bd12f98a66c3 -r f3768d0d65a2 Frameworks/AutoHyperlinks Framework/AutoHyperlinks.framework.xcodeproj/project.pbxproj
--- a/Frameworks/AutoHyperlinks Framework/AutoHyperlinks.framework.xcodeproj/project.pbxproj	Tue Apr 27 11:09:33 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/AutoHyperlinks.framework.xcodeproj/project.pbxproj	Tue Apr 27 20:31:08 2010 -0700
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 45;
+	objectVersion = 46;
 	objects = {
 
 /* Begin PBXBuildFile section */
@@ -68,6 +68,10 @@
 		3496A82007CE69270055BBAB /* AHHyperlinkScanner.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AHHyperlinkScanner.m; path = Source/AHHyperlinkScanner.m; sourceTree = "<group>"; };
 		3496A82107CE69270055BBAB /* AHHyperlinkScanner.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AHHyperlinkScanner.h; path = Source/AHHyperlinkScanner.h; sourceTree = "<group>"; };
 		3496A82207CE69270055BBAB /* AHMarkedHyperlink.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AHMarkedHyperlink.m; path = Source/AHMarkedHyperlink.m; sourceTree = "<group>"; };
+		7E0CF1AF11769E6100EDC305 /* AutoHyperlinks.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = AutoHyperlinks.xcconfig; path = xcconfigs/AutoHyperlinks.xcconfig; sourceTree = "<group>"; };
+		7E0CF30C11769F4C00EDC305 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = xcconfigs/Debug.xcconfig; sourceTree = "<group>"; };
+		7E0CF31811769FBD00EDC305 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = xcconfigs/Release.xcconfig; sourceTree = "<group>"; };
+		7E0CF31B11769FE700EDC305 /* Release-Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "Release-Debug.xcconfig"; path = "xcconfigs/Release-Debug.xcconfig"; sourceTree = "<group>"; };
 		7E4C24320DD20C0100DF1359 /* NegativeURLTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NegativeURLTest.h; path = UnitTests/NegativeURLTest.h; sourceTree = "<group>"; };
 		7E4C24330DD20C0100DF1359 /* NegativeURLTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NegativeURLTest.m; path = UnitTests/NegativeURLTest.m; sourceTree = "<group>"; };
 		7E4C24360DD20C9900DF1359 /* HyperlinkContextTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HyperlinkContextTest.h; path = UnitTests/HyperlinkContextTest.h; sourceTree = "<group>"; };
@@ -169,6 +173,7 @@
 				089C1665FE841158C02AAC07 /* Resources */,
 				0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,
 				034768DFFF38A50411DB9C8B /* Products */,
+				7E0CF1A011769DE400EDC305 /* xcconfigs */,
 			);
 			name = AIHyperlinks.framework;
 			sourceTree = "<group>";
@@ -241,6 +246,17 @@
 			name = "Other Sources";
 			sourceTree = "<group>";
 		};
+		7E0CF1A011769DE400EDC305 /* xcconfigs */ = {
+			isa = PBXGroup;
+			children = (
+				7E0CF31B11769FE700EDC305 /* Release-Debug.xcconfig */,
+				7E0CF1AF11769E6100EDC305 /* AutoHyperlinks.xcconfig */,
+				7E0CF30C11769F4C00EDC305 /* Debug.xcconfig */,
+				7E0CF31811769FBD00EDC305 /* Release.xcconfig */,
+			);
+			name = xcconfigs;
+			sourceTree = "<group>";
+		};
 		7EA3B03C0DD1150E002A18D1 /* UnitTests */ = {
 			isa = PBXGroup;
 			children = (
@@ -381,10 +397,10 @@
 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				BuildIndependentTargetsInParallel = NO;
+				BuildIndependentTargetsInParallel = YES;
 			};
 			buildConfigurationList = DA8A8087085549EE00F24BB3 /* Build configuration list for PBXProject "AutoHyperlinks.framework" */;
-			compatibilityVersion = "Xcode 3.1";
+			compatibilityVersion = "Xcode 3.2";
 			hasScannedForEncodings = 1;
 			mainGroup = 0867D691FE84028FC02AAC07 /* AIHyperlinks.framework */;
 			productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
@@ -520,7 +536,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -529,7 +544,6 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = Debug;
 		};
@@ -548,7 +562,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				MACOSX_DEPLOYMENT_TARGET = 10.5;
 				OTHER_LDFLAGS = (
 					"-framework",
@@ -558,7 +571,6 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = Release;
 		};
@@ -576,7 +588,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -585,13 +596,13 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = "Release-Debug";
 		};
 		34C57363093E5E6E00829508 /* Release-Debug */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
 				COPY_PHASE_STRIP = NO;
 				DEPLOYMENT_POSTPROCESSING = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1;
@@ -603,8 +614,6 @@
 				GCC_PREFIX_HEADER = AutoHyperlinks.framework_Prefix.pch;
 				INFOPLIST_FILE = Resources/Info.plist;
 				INSTALL_PATH = "@executable_path/../Frameworks";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
-				LIBRARY_STYLE = DYNAMIC;
 				MACH_O_TYPE = mh_dylib;
 				PREBINDING = NO;
 				PRODUCT_NAME = AutoHyperlinks;
@@ -616,20 +625,8 @@
 		};
 		34C57364093E5E6E00829508 /* Release-Debug */ = {
 			isa = XCBuildConfiguration;
+			baseConfigurationReference = 7E0CF31B11769FE700EDC305 /* Release-Debug.xcconfig */;
 			buildSettings = {
-				APPLY_RULES_IN_COPY_FILES = YES;
-				ARCHS = (
-					x86_64,
-					i386,
-					ppc,
-				);
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_VERSION = 4.2;
-				INFOPLIST_OUTPUT_FORMAT = binary;
-				LD_DYLIB_INSTALL_NAME = "@rpath/AutoHyperlinks.framework/Versions/A/AutoHyperlinks";
-				PLIST_FILE_OUTPUT_FORMAT = binary;
-				SDKROOT = macosx10.5;
-				SYMROOT = ../../build;
 			};
 			name = "Release-Debug";
 		};
@@ -637,7 +634,6 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COPY_PHASE_STRIP = NO;
 				FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
 				GCC_DYNAMIC_NO_PIC = NO;
@@ -649,7 +645,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INFOPLIST_FILE = "Resources/Test-Info.plist";
 				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Cocoa,
@@ -666,7 +661,6 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				COPY_PHASE_STRIP = YES;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
@@ -677,7 +671,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INFOPLIST_FILE = "Resources/Test-Info.plist";
 				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Cocoa,
@@ -694,7 +687,6 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
 				GCC_ENABLE_FIX_AND_CONTINUE = NO;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -703,7 +695,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INFOPLIST_FILE = "Resources/Test-Info.plist";
 				INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Cocoa,
@@ -727,7 +718,6 @@
 				GCC_PREFIX_HEADER = LinkDriver/LinkDriver.pch;
 				INFOPLIST_FILE = "LinkDriver/LinkDriver-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -749,7 +739,6 @@
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
 				INFOPLIST_FILE = "LinkDriver/LinkDriver-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -770,7 +759,6 @@
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
 				INFOPLIST_FILE = "LinkDriver/LinkDriver-Info.plist";
 				INSTALL_PATH = "$(HOME)/Applications";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -800,7 +788,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -809,7 +796,6 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHThreadedStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = Debug;
 		};
@@ -828,7 +814,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				MACOSX_DEPLOYMENT_TARGET = 10.5;
 				OTHER_LDFLAGS = (
 					"-framework",
@@ -838,7 +823,6 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHThreadedStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = Release;
 		};
@@ -856,7 +840,6 @@
 				GCC_PREPROCESSOR_DEFINITIONS = "TEST_URIS_FILE_PATHNAME=\"\\\"$(SRCROOT)/TestURIs.txt\\\"\"";
 				INSTALL_PATH = /usr/local/bin;
 				LD_RUNPATH_SEARCH_PATHS = "$(DEVELOPER_FRAMEWORKS_DIR)";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
 				OTHER_LDFLAGS = (
 					"-framework",
 					Foundation,
@@ -865,7 +848,6 @@
 				);
 				PREBINDING = NO;
 				PRODUCT_NAME = AHThreadedStressTester;
-				SDKROOT = macosx10.5;
 			};
 			name = "Release-Debug";
 		};
@@ -883,10 +865,7 @@
 				GCC_PREFIX_HEADER = AutoHyperlinks.framework_Prefix.pch;
 				INFOPLIST_FILE = Resources/Info.plist;
 				INSTALL_PATH = "@executable_path/../Frameworks";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
-				LIBRARY_STYLE = DYNAMIC;
 				MACH_O_TYPE = mh_dylib;
-				ONLY_ACTIVE_ARCH = YES;
 				PREBINDING = NO;
 				PRODUCT_NAME = AutoHyperlinks;
 				SKIP_INSTALL = YES;
@@ -898,6 +877,7 @@
 		DA8A8085085549EE00F24BB3 /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
 				COPY_PHASE_STRIP = YES;
 				DEPLOYMENT_POSTPROCESSING = YES;
 				DYLIB_COMPATIBILITY_VERSION = 1;
@@ -909,8 +889,6 @@
 				GCC_PREFIX_HEADER = AutoHyperlinks.framework_Prefix.pch;
 				INFOPLIST_FILE = Resources/Info.plist;
 				INSTALL_PATH = "@executable_path/../Frameworks";
-				LEX = "$(SRCROOT)/Utilities/usr/bin/flex";
-				LIBRARY_STYLE = DYNAMIC;
 				MACH_O_TYPE = mh_dylib;
 				PREBINDING = NO;
 				PRODUCT_NAME = AutoHyperlinks;
@@ -923,33 +901,15 @@
 		};
 		DA8A8088085549EE00F24BB3 /* Debug */ = {
 			isa = XCBuildConfiguration;
+			baseConfigurationReference = 7E0CF30C11769F4C00EDC305 /* Debug.xcconfig */;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_ACTUAL)";
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_VERSION = 4.2;
-				LD_DYLIB_INSTALL_NAME = "@rpath/AutoHyperlinks.framework/Versions/A/AutoHyperlinks";
-				ONLY_ACTIVE_ARCH = YES;
-				SDKROOT = macosx10.5;
-				SYMROOT = ../../build;
 			};
 			name = Debug;
 		};
 		DA8A8089085549EE00F24BB3 /* Release */ = {
 			isa = XCBuildConfiguration;
+			baseConfigurationReference = 7E0CF31811769FBD00EDC305 /* Release.xcconfig */;
 			buildSettings = {
-				APPLY_RULES_IN_COPY_FILES = YES;
-				ARCHS = (
-					x86_64,
-					i386,
-					ppc,
-				);
-				GCC_C_LANGUAGE_STANDARD = gnu99;
-				GCC_VERSION = 4.2;
-				INFOPLIST_OUTPUT_FORMAT = binary;
-				LD_DYLIB_INSTALL_NAME = "@rpath/AutoHyperlinks.framework/Versions/A/AutoHyperlinks";
-				PLIST_FILE_OUTPUT_FORMAT = binary;
-				SDKROOT = macosx10.5;
-				SYMROOT = ../../build;
 			};
 			name = Release;
 		};
diff -r bd12f98a66c3 -r f3768d0d65a2 Frameworks/AutoHyperlinks Framework/License.txt
--- a/Frameworks/AutoHyperlinks Framework/License.txt	Tue Apr 27 11:09:33 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/License.txt	Tue Apr 27 20:31:08 2010 -0700
@@ -2,7 +2,7 @@
  * The AutoHyperlinks Framework is the legal property of its developers (DEVELOPERS), whose names are listed in the
  * copyright file included with this source distribution.
  *
- * Copyright (c) 2004-2008
+ * Copyright (c) 2004-2010
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
diff -r bd12f98a66c3 -r f3768d0d65a2 Frameworks/AutoHyperlinks Framework/LinkDriver/LinkDriverWindowController.m
--- a/Frameworks/AutoHyperlinks Framework/LinkDriver/LinkDriverWindowController.m	Tue Apr 27 11:09:33 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/LinkDriver/LinkDriverWindowController.m	Tue Apr 27 20:31:08 2010 -0700
@@ -11,6 +11,14 @@
 #define VIEW_KEY @"linkView"
 
 @implementation LinkDriverWindowController
+-(void) performLinkification:(NSTextView *)inView
+{
+	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+	AHHyperlinkScanner	*scanner = [AHHyperlinkScanner hyperlinkScannerWithAttributedString:[inView textStorage]];
+	[[inView textStorage] setAttributedString:[scanner linkifiedString]];
+	[pool release];
+}
+
 -(IBAction) linkifyTextView:(id)sender {
 	[NSThread	detachNewThreadSelector:@selector(performLinkification:)
 							   toTarget:self
@@ -19,16 +27,4 @@
 							   toTarget:self
 							 withObject:otherView];
 }
-
--(void) performLinkification:(NSTextView *)inView
-{
-	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-	AHHyperlinkScanner	*scanner = [AHHyperlinkScanner hyperlinkScannerWithAttributedString:[inView textStorage]];
-	NSAttributedString *attributedString = [scanner linkifiedString];
-	
-	[[inView textStorage] performSelectorOnMainThread:@selector(setAttributedString:)
-										   withObject:attributedString
-										waitUntilDone:NO];
-	[pool release];
-}
 @end
diff -r bd12f98a66c3 -r f3768d0d65a2 Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.h
--- a/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.h	Tue Apr 27 11:09:33 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.h	Tue Apr 27 20:31:08 2010 -0700
@@ -29,11 +29,12 @@
 
 typedef void* yyscan_t;
 
-extern long AHlex( yyscan_t yyscanner );
-extern long AHlex_init( yyscan_t * ptr_yy_globals );
-extern long AHlex_destroy ( yyscan_t yyscanner );
-extern long AHget_leng ( yyscan_t scanner );
-extern void AHset_in ( FILE * in_str , yyscan_t scanner );
+extern long				AHlex( yyscan_t yyscanner );
+extern long				AHlex_init( yyscan_t * ptr_yy_globals );
+extern long				AHlex_destroy ( yyscan_t yyscanner );
+extern long				AHget_leng ( yyscan_t scanner );
+extern void				AHset_in ( FILE * in_str , yyscan_t scanner );
+extern YY_EXTRA_TYPE	AHget_extra ( yyscan_t scanner );
 
 typedef struct AH_buffer_state *AH_BUFFER_STATE;
 extern void AH_switch_to_buffer(AH_BUFFER_STATE, yyscan_t scanner);
@@ -46,8 +47,12 @@
 {
 	NSDictionary        *m_urlSchemes;
 	NSString            *m_scanString;
+#ifdef TARGET_OS_IPHONE
+	NSString            *m_linkifiedString
+#else
 	NSAttributedString  *m_scanAttrString;
 	NSAttributedString  *m_linkifiedString;
+#endif
 	BOOL                 m_strictChecking;
 	unsigned long        m_scanLocation;
 	unsigned long        m_scanStringLength;
@@ -72,6 +77,7 @@
  */
 + (id)strictHyperlinkScannerWithString:(NSString *)inString;
 
+#ifndef TARGET_OS_IPHONE
 /*!
  * @brief Allocs and inits a new lax AHHyperlinkScanner with the given attributed string
  *
@@ -87,6 +93,7 @@
  * @return a new AHHyperlinkScanner
  */
 + (id)strictHyperlinkScannerWithAttributedString:(NSAttributedString *)inString;
+#endif
 
 /*!
  * @brief Determine the validity of a given string with a custom strictness
@@ -96,7 +103,7 @@
  * @param index a pointer to the index the string starts at, for easy incrementing.
  * @return Boolean
  */
-+ (BOOL)isStringValidURI:(NSString *)inString usingStrict:(BOOL)useStrictChecking fromIndex:(unsigned long *)index withStatus:(AH_URI_VERIFICATION_STATUS *)validStatus;
++ (BOOL)isStringValidURI:(NSString *)inString usingStrict:(BOOL)useStrictChecking fromIndex:(unsigned long *)index withStatus:(AH_URI_VERIFICATION_STATUS *)validStatus schemeLength:(unsigned long *)schemeLength;
 
 /*!
  * @brief Init
@@ -109,6 +116,7 @@
  */
 - (id)initWithString:(NSString *)inString usingStrictChecking:(BOOL)flag;
 
+#ifndef TARGET_OS_IPHONE
 /*!
  * @brief Init
  *
@@ -118,8 +126,8 @@
  * @param flag Sets strict checking preference.
  * @return A new AHHyperlinkScanner.
  */
- - (id)initWithAttributedString:(NSAttributedString *)inString usingStrictChecking:(BOOL)flag;
-
+- (id)initWithAttributedString:(NSAttributedString *)inString usingStrictChecking:(BOOL)flag;
+#endif
 
 /*!
  * @brief Determine the validity of the scanner's string using the set strictness
@@ -142,11 +150,18 @@
  */
 - (NSArray *)allURIs;
 
+#ifdef TARGET_OS_IPHONE
 /*!
- * @brief Scans an attributed string for URIs then adds the link attribs and objects.
- * @param inString The NSAttributedString to be linkified
+ * @brief Scans the stored string for URIs then adds the link attribs and objects.
+ * @return An autoreleased NSString.
+ */
+- (NSString *)linkifiedString;
+#else
+/*!
+ * @brief Scans the stored string for URIs then adds the link attribs and objects.
  * @return An autoreleased NSAttributedString.
  */
 - (NSAttributedString *)linkifiedString;
+#endif
 
 @end
diff -r bd12f98a66c3 -r f3768d0d65a2 Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m
--- a/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m	Tue Apr 27 11:09:33 2010 -0500
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHHyperlinkScanner.m	Tue Apr 27 20:31:08 2010 -0700
@@ -30,13 +30,17 @@
 #import "AHMarkedHyperlink.h"
 #import <libkern/OSAtomic.h>
 
-#define	DEFAULT_URL_SCHEME	@"http://"
+#define DEFAULT_URL_SCHEME @"http://"
 #define ENC_INDEX_KEY @"encIndex"
 #define ENC_CHAR_KEY @"encChar"
 
 @interface AHHyperlinkScanner (PRIVATE)
 - (AHMarkedHyperlink *)nextURIFromLocation:(unsigned long *)_scanLocation;
+#ifdef TARGET_OS_IPHONE
+- (NSString *)_createLinkifiedString;
+#else
 - (NSAttributedString *)_createLinkifiedString;
+#endif
 - (NSRange)_longestBalancedEnclosureInRange:(NSRange)inRange;
 - (BOOL)_scanString:(NSString *)inString upToCharactersFromSet:(NSCharacterSet *)inCharSet intoRange:(NSRange *)outRangeRef fromIndex:(unsigned long *)idx;
 - (BOOL)_scanString:(NSString *)inString charactersFromSet:(NSCharacterSet *)inCharSet intoRange:(NSRange *)outRangeRef fromIndex:(unsigned long *)idx;
@@ -57,6 +61,35 @@
 @synthesize scanLocation = m_scanLocation;
 @dynamic linkifiedString;
 
+#pragma mark runtime initialization
++ (void)initialize
+{
+	if (self == [AHHyperlinkScanner class]){
+		NSMutableCharacterSet *mutableSkipSet = [[NSMutableCharacterSet alloc] init];
+		[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+		[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet illegalCharacterSet]];
+		[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet controlCharacterSet]];
+		[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
+		skipSet = [[NSCharacterSet characterSetWithBitmapRepresentation:[mutableSkipSet bitmapRepresentation]] retain];
+		[mutableSkipSet release];
+		
+		endSet = [[NSCharacterSet characterSetWithCharactersInString:@"\"',:;>)]}.?!@"] retain];
+		
+		NSMutableCharacterSet *mutableStartSet = [[NSMutableCharacterSet alloc] init];
+		[mutableStartSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+		[mutableStartSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"\"'.,:;<?!-@%C%C", 0x2014, 0x2013]]];
+		startSet = [[NSCharacterSet characterSetWithBitmapRepresentation:[mutableStartSet bitmapRepresentation]] retain];
+		[mutableStartSet release];
+		
+		puncSet = [[NSCharacterSet characterSetWithCharactersInString:@"\"'.,:;<?!"] retain];
+		hostnameComponentSeparatorSet = [[NSCharacterSet characterSetWithCharactersInString:@"./"] retain];
+		enclosureStartArray = [[NSArray arrayWithObjects:@"(",@"[",@"{",nil] retain];
+		enclosureSet = [[NSCharacterSet characterSetWithCharactersInString:@"()[]{}"] retain];
+		enclosureStopArray = [[NSArray arrayWithObjects:@")",@"]",@"}",nil] retain];
+		encKeys = [[NSArray arrayWithObjects:ENC_INDEX_KEY, ENC_CHAR_KEY, nil] retain];
+	}
+}
+
 #pragma mark Class Methods
 + (id)hyperlinkScannerWithString:(NSString *)inString
 {
@@ -68,6 +101,7 @@
 	return [[[[self class] alloc] initWithString:inString usingStrictChecking:YES] autorelease];
 }
 
+#ifndef TARGET_OS_IPHONE
 + (id)hyperlinkScannerWithAttributedString:(NSAttributedString *)inString
 {
 	return [[[[self class] alloc] initWithAttributedString:inString usingStrictChecking:NO] autorelease];
@@ -77,58 +111,7 @@
 {
 	return [[[[self class] alloc] initWithAttributedString:inString usingStrictChecking:NO] autorelease];
 }
-
-#pragma mark Initialization
-+ (void)initialize
-{
-	if ((self == [AHHyperlinkScanner class])) {
-		if (!skipSet) {
-			NSMutableCharacterSet *mutableSkipSet = [[NSMutableCharacterSet alloc] init];
-			[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-			[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet illegalCharacterSet]];
-			[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet controlCharacterSet]];
-			[mutableSkipSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
-			skipSet = [[NSCharacterSet characterSetWithBitmapRepresentation:[mutableSkipSet bitmapRepresentation]] retain];
-			[mutableSkipSet release];
-		}
-		
-		if (!endSet) {
-			endSet = [[NSCharacterSet characterSetWithCharactersInString:@"\"',:;>)]}.?!@"] retain];
-		}
-		
-		if (!startSet) {
-			NSMutableCharacterSet *mutableStartSet = [[NSMutableCharacterSet alloc] init];
-			[mutableStartSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-			[mutableStartSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"\"'.,:;<?!-@%C%C", 0x2014, 0x2013]]];
-			startSet = [[NSCharacterSet characterSetWithBitmapRepresentation:[mutableStartSet bitmapRepresentation]] retain];
-			[mutableStartSet release];
-		}
-		
-		if (!puncSet) {
-			puncSet = [[NSCharacterSet characterSetWithCharactersInString:@"\"'.,:;<?!"] retain];
-		}
-		
-		if (!hostnameComponentSeparatorSet) {
-			hostnameComponentSeparatorSet = [[NSCharacterSet characterSetWithCharactersInString:@"./"] retain];
-		}
-		
-		if(!enclosureStartArray){
-			enclosureStartArray = [[NSArray arrayWithObjects:@"(",@"[",@"{",nil] retain];
-		}
-		
-		if(!enclosureSet){
-			enclosureSet = [[NSCharacterSet characterSetWithCharactersInString:@"()[]{}"] retain];
-		}
-		
-		if(!enclosureStopArray){
-			enclosureStopArray = [[NSArray arrayWithObjects:@")",@"]",@"}",nil] retain];
-		}
-		
-		if(!encKeys){
-			encKeys = [[NSArray arrayWithObjects:ENC_INDEX_KEY, ENC_CHAR_KEY, nil] retain];
-		}		
-	}
-}
+#endif
 
 #pragma mark Init/Dealloc
 - (id)init
@@ -136,37 +119,41 @@
 	if((self = [super init])){
 		self.scanLocation = 0;
 		m_linkifiedString = nil;
+#ifndef TARGET_OS_IPHONE
+		m_scanAttrString = nil;
+#endif
 	}
 	return self;
 }
 
 - (id)initWithString:(NSString *)inString usingStrictChecking:(BOOL)flag
 {
-	if((self = [self init])){
+	if((self = [super init])){
 		m_scanString = [inString retain];
-		m_scanAttrString = nil;
 		m_urlSchemes = [[NSDictionary alloc] initWithObjectsAndKeys:
-			@"ftp://", @"ftp",
-			nil];
+						@"ftp://", @"ftp",
+						nil];
 		m_strictChecking = flag;
 		m_scanStringLength = [m_scanString length];
 	}
 	return self;
 }
 
+#ifndef TARGET_OS_IPHONE
 - (id)initWithAttributedString:(NSAttributedString *)inString usingStrictChecking:(BOOL)flag
 {
-	if((self = [self init])){
+	if((self = [super init])){
 		m_scanString = [[inString string] retain];
 		m_scanAttrString = [inString retain];
 		m_urlSchemes = [[NSDictionary alloc] initWithObjectsAndKeys:
-			@"ftp://", @"ftp",
-			nil];
+						@"ftp://", @"ftp",
+						nil];
 		m_strictChecking = flag;
 		m_scanStringLength = [m_scanString length];
 	}
 	return self;
 }
+#endif
 
 - (void)dealloc
 {
@@ -182,15 +169,15 @@
 
 - (BOOL)isValidURI
 {
-	return [AHHyperlinkScanner isStringValidURI:m_scanString usingStrict:m_strictChecking fromIndex:nil withStatus:nil];
+	return [AHHyperlinkScanner isStringValidURI:m_scanString usingStrict:m_strictChecking fromIndex:nil withStatus:nil schemeLength:nil];
 }
 
-+ (BOOL)isStringValidURI:(NSString *)inString usingStrict:(BOOL)useStrictChecking fromIndex:(unsigned long *)index withStatus:(AH_URI_VERIFICATION_STATUS *)validStatus
++ (BOOL)isStringValidURI:(NSString *)inString usingStrict:(BOOL)useStrictChecking fromIndex:(unsigned long *)sIndex withStatus:(AH_URI_VERIFICATION_STATUS *)validStatus schemeLength:(unsigned long *)schemeLength
 {
-	AH_BUFFER_STATE	 buf; // buffer for flex to scan from
+    AH_BUFFER_STATE	 buf;  // buffer for flex to scan from
 	yyscan_t		 scanner; // pointer to the flex scanner opaque type
 	const char		*inStringEnc;
-	unsigned long	 encodedLength;
+    unsigned long	 encodedLength;
 	
 	if(!validStatus){
 		AH_URI_VERIFICATION_STATUS newStatus = AH_URL_INVALID;
@@ -210,69 +197,62 @@
 	
 	
 	encodedLength = strlen(inStringEnc); // length of the string in utf-8
-	
+    
 	// initialize the buffer (flex automatically switches to the buffer in this function)
 	AHlex_init(&scanner);
-	buf = AH_scan_string(inStringEnc, scanner);
+    buf = AH_scan_string(inStringEnc, scanner);
 	
-	// call flex to parse the input
-	*validStatus = AHlex(scanner);
-	if(index) *index += AHget_leng(scanner);
+    // call flex to parse the input
+    *validStatus = (AH_URI_VERIFICATION_STATUS)AHlex(scanner);
+	if(sIndex) *sIndex += AHget_leng(scanner);
+	if(schemeLength) *schemeLength = AHget_extra(scanner).schemeLength;
 	
-	// condition for valid URI's
-	if(*validStatus == AH_URL_VALID || *validStatus == AH_MAILTO_VALID || *validStatus == AH_FILE_VALID){
-		AH_delete_buffer(buf, scanner); //remove the buffer from flex.
-		buf = NULL; //null the buffer pointer for safty's sake.
-		
-		// check that the whole string was matched by flex.
-		// this prevents silly things like "blah...com" from being seen as links
-		if(AHget_leng(scanner) == encodedLength){
+    // condition for valid URI's
+    if(*validStatus == AH_URL_VALID || *validStatus == AH_MAILTO_VALID || *validStatus == AH_FILE_VALID){
+        AH_delete_buffer(buf, scanner); //remove the buffer from flex.
+        buf = NULL; //null the buffer pointer for safty's sake.
+        
+        // check that the whole string was matched by flex.
+        // this prevents silly things like "blah...com" from being seen as links
+        if(AHget_leng(scanner) == encodedLength){
 			AHlex_destroy(scanner);
-			return YES;
-		}
-    // condition for degenerate URL's (A.K.A. URI's sans specifiers), requres strict checking to be NO.
-	}else if((*validStatus == AH_URL_DEGENERATE || *validStatus == AH_MAILTO_DEGENERATE) && !useStrictChecking){
-		AH_delete_buffer(buf, scanner);
-		buf = NULL;
-		if(AHget_leng(scanner) == encodedLength){
+            return YES;
+        }
+		// condition for degenerate URL's (A.K.A. URI's sans specifiers), requres strict checking to be NO.
+    }else if((*validStatus == AH_URL_DEGENERATE || *validStatus == AH_MAILTO_DEGENERATE || *validStatus == AH_URL_TENTATIVE) && !useStrictChecking){
+        AH_delete_buffer(buf, scanner);
+        buf = NULL;
+        if(AHget_leng(scanner) == encodedLength){
 			AHlex_destroy(scanner);
-			return YES;
-		}
-    // if it ain't vaild, and it ain't degenerate, then it's invalid.
-	}else{
-		AH_delete_buffer(buf, scanner);
-		buf = NULL;
+            return YES;
+        }
+		// if it ain't vaild, and it ain't degenerate, then it's invalid.
+    }else{
+        AH_delete_buffer(buf, scanner);
+        buf = NULL;
 		AHlex_destroy(scanner);
-		return NO;
-	}
-	// default case, if the range checking above fails.
+        return NO;
+    }
+    // default case, if the range checking above fails.
 	AHlex_destroy(scanner);
-	return NO;
+    return NO;
 }
 
 #pragma mark Accessors
 
-- (AHMarkedHyperlink *)nextURIFromLocation:(unsigned long * const)_scanLocation
+- (AHMarkedHyperlink *)nextURI
 {
-	NSRange	scannedRange = NSMakeRange(0, 0);
-	unsigned long scannedLocation = *_scanLocation;
+	NSRange	scannedRange;
+	unsigned long scannedLocation = m_scanLocation;
 	
-	// scan upto the next whitespace char so that we don't unnecessarity confuse flex
-	// otherwise we end up validating urls that look like this "http://www.adium.im/ <--cool"
+    // scan upto the next whitespace char so that we don't unnecessarity confuse flex
+    // otherwise we end up validating urls that look like this "http://www.adium.im/ <--cool"
 	[self _scanString:m_scanString charactersFromSet:startSet intoRange:nil fromIndex:&scannedLocation];
 	
 	// main scanning loop
 	while([self _scanString:m_scanString upToCharactersFromSet:skipSet intoRange:&scannedRange fromIndex:&scannedLocation]) {
 		
-		// back off if the last character is puncuation.
-		unichar s_char = [m_scanString characterAtIndex:(scannedRange.location + scannedRange.length - 1)];
-		if(4 < scannedRange.length && [puncSet characterIsMember:s_char]) {
-			scannedRange.length--;
-		}
-		
-		BOOL foundUnpairedEnclosureCharacter = NO;
-		
-		// Check for and filter enclosures.  We can't add (, [, etc. to the skipSet as they may be in a URI
+		// Check for and filter  enclosures.  We can't add (, [, etc. to the skipSet as they may be in a URI
 		if([enclosureSet characterIsMember:[m_scanString characterAtIndex:scannedRange.location]]){
 			unsigned long encIdx = [enclosureStartArray indexOfObject:[m_scanString substringWithRange:NSMakeRange(scannedRange.location, 1)]];
 			NSRange encRange;
@@ -280,8 +260,6 @@
 				encRange = [m_scanString rangeOfString:[enclosureStopArray objectAtIndex:encIdx] options:NSBackwardsSearch range:scannedRange];
 				if(NSNotFound != encRange.location){
 					scannedRange.location++; scannedRange.length -= 2;
-				}else{
-					foundUnpairedEnclosureCharacter = YES;
 				}
 			}
 		}
@@ -292,100 +270,133 @@
 		while (scannedRange.length > 2 && [endSet characterIsMember:[m_scanString characterAtIndex:(scannedRange.location + scannedRange.length - 1)]]) {
 			if((longestEnclosure.location + longestEnclosure.length) < scannedRange.length){
 				scannedRange.length--;
-				foundUnpairedEnclosureCharacter = NO;
 			}else break;
 		}
 		
-		// if we have a valid URL then save the scanned string, and make a SHMarkedHyperlink out of it.
-		// this way, we can preserve things like the matched string (to be converted to a NSURL),
-		// parent string, its validation status (valid, file, degenerate, etc), and its range in the parent string
+        // if we have a valid URL then save the scanned string, and make a SHMarkedHyperlink out of it.
+        // this way, we can preserve things like the matched string (to be converted to a NSURL),
+        // parent string, its validation status (valid, file, degenerate, etc), and its range in the parent string
 		AH_URI_VERIFICATION_STATUS	 validStatus;
 		NSString					*_scanString = nil;
+		unsigned long				 schemeLength = 0;
 		if(3 < scannedRange.length) _scanString = [m_scanString substringWithRange:scannedRange];
-		
-		if((3 < scannedRange.length) && [[self class] isStringValidURI:_scanString usingStrict:m_strictChecking fromIndex:_scanLocation withStatus:&validStatus]){
-			AHMarkedHyperlink	*markedLink;
-			
-			//insert typical specifiers if the URL is degenerate
-			switch(validStatus){
-				case AH_URL_DEGENERATE:
-			 {
-				NSString *scheme = DEFAULT_URL_SCHEME;
-				unsigned long i = 0;
-				
-				NSRange  firstComponent;
-				[self		  _scanString:_scanString
-			 upToCharactersFromSet:hostnameComponentSeparatorSet
-									 intoRange:&firstComponent
-									 fromIndex:&i];
-				
-				if(NSNotFound != firstComponent.location) {
-					NSString *hostnameScheme = [m_urlSchemes objectForKey:[_scanString substringWithRange:firstComponent]];
-					if(hostnameScheme) scheme = hostnameScheme;
+        if((3 < scannedRange.length) && [[self class] isStringValidURI:_scanString usingStrict:m_strictChecking fromIndex:&m_scanLocation withStatus:&validStatus schemeLength:&schemeLength]){
+            AHMarkedHyperlink	*markedLink;
+			BOOL				 makeLink = TRUE;
+            //insert typical specifiers if the URL is degenerate
+            switch(validStatus){
+                case AH_URL_DEGENERATE:
+                {
+                    NSString *scheme = DEFAULT_URL_SCHEME;
+					unsigned long i = 0;
+					
+                    NSRange  firstComponent;
+					[self		  _scanString:_scanString
+				   upToCharactersFromSet:hostnameComponentSeparatorSet
+							   intoRange:&firstComponent
+							   fromIndex:&i];
+					
+                    if(NSNotFound != firstComponent.location) {
+                    	NSString *hostnameScheme = [m_urlSchemes objectForKey:[_scanString substringWithRange:firstComponent]];
+                    	if(hostnameScheme) scheme = hostnameScheme;
+                    }
+					
+                    _scanString = [scheme stringByAppendingString:_scanString];
+					
+                    break;
+                }
+					
+                case AH_MAILTO_DEGENERATE:
+					_scanString = [@"mailto:" stringByAppendingString:_scanString];
+                    break;
+				case AH_URL_TENTATIVE:
+				{
+					NSString *scheme = [_scanString substringToIndex:schemeLength];
+					NSString *app = (NSString *)LSCopyDefaultHandlerForURLScheme((CFStringRef)scheme);
+
+					if(!app)
+						makeLink = FALSE;
+					[app release];
+					break;
 				}
-				
-				_scanString = [scheme stringByAppendingString:_scanString];
-				
-				break;
-			 }
-					
-				case AH_MAILTO_DEGENERATE:
-					_scanString = [@"mailto:" stringByAppendingString:_scanString];
-					break;
-				default:
-					break;
+                default:
+                    break;
+            }
+            
+			if(makeLink){
+				//make a marked link
+				markedLink = [[AHMarkedHyperlink alloc] initWithString:_scanString
+												  withValidationStatus:validStatus
+														  parentString:m_scanString
+															  andRange:scannedRange];
+				return [markedLink autorelease];
 			}
-			
-			//make a marked link
-			markedLink = [AHMarkedHyperlink hyperlinkWithString:_scanString
-																		 withValidationStatus:validStatus
-																						 parentString:m_scanString
-																								 andRange:scannedRange];
-			return [markedLink URL]? markedLink : nil;
-		}
+        }
 		
 		//step location after scanning a string
-		if (foundUnpairedEnclosureCharacter){
-			(*_scanLocation)++;
-		}else{
-			NSRange startRange = [m_scanString rangeOfCharacterFromSet:puncSet options:NSLiteralSearch range:scannedRange];
-			if (startRange.location != NSNotFound)
-				*_scanLocation = startRange.location + startRange.length;
-			else
-				*_scanLocation += scannedRange.length;
-		}
+		NSRange startRange = [m_scanString rangeOfCharacterFromSet:puncSet options:NSLiteralSearch range:scannedRange];
+		if (startRange.location != NSNotFound)
+			m_scanLocation = startRange.location + startRange.length;
+		else
+			m_scanLocation += scannedRange.length;
 		
-		scannedLocation = *_scanLocation;
-	}
+		scannedLocation = m_scanLocation;
+    }
 	
-	// if we're here, then NSScanner hit the end of the string
-	// set AHStringOffset to the string length here so we avoid potential infinite looping with many trailing spaces.
-	*_scanLocation = m_scanStringLength;
-	return nil;
-}
-
-- (AHMarkedHyperlink *)nextURI
-{
-	AHMarkedHyperlink *link = nil;
-	@synchronized(self) {
-		link = [self nextURIFromLocation:&m_scanLocation];
-	}
-	return link;
+    // if we're here, then NSScanner hit the end of the string
+    // set AHStringOffset to the string length here so we avoid potential infinite looping with many trailing spaces.
+    m_scanLocation = m_scanStringLength;
+    return nil;
 }
 
 -(NSArray *)allURIs
 {
-	NSMutableArray    *rangeArray = [NSMutableArray array];
-	AHMarkedHyperlink *markedLink;
-	unsigned long      offset = 0;
-	
-	//build an array of marked links.
-	while((markedLink = [self nextURIFromLocation:&offset])){
+    NSMutableArray		*rangeArray = [NSMutableArray array];
+    AHMarkedHyperlink	*markedLink;
+	unsigned long		 _holdOffset = m_scanLocation; // store location for later restoration;
+	m_scanLocation = 0; //set the offset to 0.
+    
+    //build an array of marked links.
+	while((markedLink = [self nextURI])){
 		[rangeArray addObject:markedLink];
 	}
+    m_scanLocation = _holdOffset; // reset scanLocation
 	return rangeArray;
 }
 
+#ifdef TARGET_OS_IPHONE
+-(NSString *)_createLinkifiedString
+{
+	NSMutableString       *_linkifiedString;
+	AHMarkedHyperlink     *markedLink;
+	unsigned long          _scanLocationCache = self.scanLocation;
+	NSEnumerator          *linkEnumerator = [[self allURIs] reverseObjectEnumerator];
+	
+	_linkifiedString = [[[NSMutableString alloc] initWithString:m_scanString] autorelease];
+	
+	while ((markedLink = [linkEnumerator nextObject])) {
+		[_linkifiedString replaceCharactersInRange:markedLink.range
+		                                withString:[NSString stringWithFormat:@"<a href=\"%@\">%@</a>",
+		                                                                      markedLink.URL,
+		                                                                      [m_scanString substringWithRange:markedLink.range]]];
+	}
+	
+	self.scanLocation = _scanLocationCache;
+	return [[_linkifiedString copy] autorelease];
+}
+
+-(NSString *)linkifiedString
+{
+	if(!m_linkifiedString){
+		NSString *newLinkifiedString = [self _createLinkifiedString];
+		// compare the old object to nil, and swap in the new value if they match.
+		// if the old object (m_linkifiedString) already has a value, release the duplicated new object
+		if(OSAtomicCompareAndSwapPtrBarrier(nil, newLinkifiedString, (void *)&m_linkifiedString))
+			[m_linkifiedString retain];
+	}
+	return m_linkifiedString;
+}
+#else
 -(NSAttributedString *)_createLinkifiedString
 {
 	NSMutableAttributedString	*_linkifiedString;
@@ -398,21 +409,21 @@
 	} else {
 		_linkifiedString = [[[NSMutableAttributedString alloc] initWithString:m_scanString] autorelease];
 	}




More information about the commits mailing list