├── .gitignore ├── aboo_Prefix.pch ├── License.rtf ├── aboo.1 ├── aboo.xcodeproj ├── project.pbxproj ├── chneeb.pbxuser └── chneeb.mode1v3 ├── RegexKitLite.h ├── aboo.m └── RegexKitLite.m /.gitignore: -------------------------------------------------------------------------------- 1 | aboo.xcodeproj/project.xcworkspace/ 2 | aboo.xcodeproj/xcuserdata/ 3 | -------------------------------------------------------------------------------- /aboo_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'aboo' target in the 'aboo' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /License.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430 2 | {\fonttbl\f0\fnil\fcharset0 LucidaGrande;\f1\fmodern\fcharset0 Courier;} 3 | {\colortbl;\red255\green255\blue255;} 4 | {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1}} 5 | {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}} 6 | \margl1440\margr1440\vieww17240\viewh12660\viewkind0 7 | \deftab720 8 | \pard\pardeftab720\sa180\ql\qnatural 9 | 10 | \f0\b\fs38 \cf0 RegexKitLite License\ 11 | \pard\pardeftab720\sa240\ql\qnatural 12 | 13 | \b0\fs24 \cf0 Copyright \'a9 2008-2009, John Engelhart\ 14 | All rights reserved.\ 15 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\ 16 | \pard\tx220\tx720\pardeftab720\li720\fi-720\sa180\ql\qnatural 17 | \ls1\ilvl0\cf0 {\listtext \'95 }Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\ 18 | {\listtext \'95 }Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\ 19 | {\listtext \'95 }Neither the name of the Zang Industries nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\ 20 | \pard\pardeftab720\sa240\ql\qnatural 21 | 22 | \f1 \cf0 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.} -------------------------------------------------------------------------------- /aboo.1: -------------------------------------------------------------------------------- 1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. 2 | .\"See Also: 3 | .\"man mdoc.samples for a complete listing of options 4 | .\"man mdoc for the short list of editing options 5 | .\"/usr/share/misc/mdoc.template 6 | .Dd 1/4/10 \" DATE 7 | .Dt aboo 1 \" Program name and manual section number 8 | .Os Darwin 9 | .Sh NAME \" Section Header - required - don't modify 10 | .Nm aboo, 11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key 12 | .\" words here as the database is built based on the words here and in the .ND line. 13 | .Nm Other_name_for_same_program(), 14 | .Nm Yet another name for the same program. 15 | .\" Use .Nm macro to designate other names for the documented program. 16 | .Nd This line parsed for whatis database. 17 | .Sh SYNOPSIS \" Section Header - required - don't modify 18 | .Nm 19 | .Op Fl abcd \" [-abcd] 20 | .Op Fl a Ar path \" [-a path] 21 | .Op Ar file \" [file] 22 | .Op Ar \" [file ...] 23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline 24 | arg2 ... \" Arguments 25 | .Sh DESCRIPTION \" Section Header - required - don't modify 26 | Use the .Nm macro to refer to your program throughout the man page like such: 27 | .Nm 28 | Underlining is accomplished with the .Ar macro like this: 29 | .Ar underlined text . 30 | .Pp \" Inserts a space 31 | A list of items with descriptions: 32 | .Bl -tag -width -indent \" Begins a tagged list 33 | .It item a \" Each item preceded by .It macro 34 | Description of item a 35 | .It item b 36 | Description of item b 37 | .El \" Ends the list 38 | .Pp 39 | A list of flags and their descriptions: 40 | .Bl -tag -width -indent \" Differs from above in tag removed 41 | .It Fl a \"-a flag as a list item 42 | Description of -a flag 43 | .It Fl b 44 | Description of -b flag 45 | .El \" Ends the list 46 | .Pp 47 | .\" .Sh ENVIRONMENT \" May not be needed 48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 49 | .\" .It Ev ENV_VAR_1 50 | .\" Description of ENV_VAR_1 51 | .\" .It Ev ENV_VAR_2 52 | .\" Description of ENV_VAR_2 53 | .\" .El 54 | .Sh FILES \" File used or created by the topic of the man page 55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact 56 | .It Pa /usr/share/file_name 57 | FILE_1 description 58 | .It Pa /Users/joeuser/Library/really_long_file_name 59 | FILE_2 description 60 | .El \" Ends the list 61 | .\" .Sh DIAGNOSTICS \" May not be needed 62 | .\" .Bl -diag 63 | .\" .It Diagnostic Tag 64 | .\" Diagnostic informtion here. 65 | .\" .It Diagnostic Tag 66 | .\" Diagnostic informtion here. 67 | .\" .El 68 | .Sh SEE ALSO 69 | .\" List links in ascending order by section, alphabetically within a section. 70 | .\" Please do not reference files that do not exist without filing a bug report 71 | .Xr a 1 , 72 | .Xr b 1 , 73 | .Xr c 1 , 74 | .Xr a 2 , 75 | .Xr b 2 , 76 | .Xr a 3 , 77 | .Xr b 3 78 | .\" .Sh BUGS \" Document known, unremedied bugs 79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner -------------------------------------------------------------------------------- /aboo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8DD76F9A0486AA7600D96B5E /* aboo.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; settings = {ATTRIBUTES = (); }; }; 11 | 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; 12 | 8DD76F9F0486AA7600D96B5E /* aboo.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* aboo.1 */; }; 13 | 969D91F010F23BFB0071FD44 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 969D91EF10F23BFB0071FD44 /* RegexKitLite.m */; }; 14 | 969D928A10F23F400071FD44 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 969D928910F23F400071FD44 /* AddressBook.framework */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXCopyFilesBuildPhase section */ 18 | 8DD76F9E0486AA7600D96B5E /* CopyFiles */ = { 19 | isa = PBXCopyFilesBuildPhase; 20 | buildActionMask = 8; 21 | dstPath = /usr/share/man/man1/; 22 | dstSubfolderSpec = 0; 23 | files = ( 24 | 8DD76F9F0486AA7600D96B5E /* aboo.1 in CopyFiles */, 25 | ); 26 | runOnlyForDeploymentPostprocessing = 1; 27 | }; 28 | /* End PBXCopyFilesBuildPhase section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 08FB7796FE84155DC02AAC07 /* aboo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = aboo.m; sourceTree = ""; }; 32 | 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 33 | 32A70AAB03705E1F00C91783 /* aboo_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aboo_Prefix.pch; sourceTree = ""; }; 34 | 8DD76FA10486AA7600D96B5E /* aboo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = aboo; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 969D91EE10F23BFB0071FD44 /* RegexKitLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegexKitLite.h; sourceTree = ""; }; 36 | 969D91EF10F23BFB0071FD44 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = ""; }; 37 | 969D928910F23F400071FD44 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; }; 38 | 969D92B110F240650071FD44 /* License.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = License.rtf; sourceTree = ""; }; 39 | 969D92B210F240650071FD44 /* RegexKitLite.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = RegexKitLite.html; sourceTree = ""; }; 40 | C6859EA3029092ED04C91782 /* aboo.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = aboo.1; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 8DD76F9B0486AA7600D96B5E /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */, 49 | 969D928A10F23F400071FD44 /* AddressBook.framework in Frameworks */, 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 08FB7794FE84155DC02AAC07 /* aboo */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 969D92AB10F240270071FD44 /* RegexKitLite-3.3 */, 60 | 08FB7795FE84155DC02AAC07 /* Source */, 61 | C6859EA2029092E104C91782 /* Documentation */, 62 | 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, 63 | 1AB674ADFE9D54B511CA2CBB /* Products */, 64 | ); 65 | name = aboo; 66 | sourceTree = ""; 67 | }; 68 | 08FB7795FE84155DC02AAC07 /* Source */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 32A70AAB03705E1F00C91783 /* aboo_Prefix.pch */, 72 | 08FB7796FE84155DC02AAC07 /* aboo.m */, 73 | ); 74 | name = Source; 75 | sourceTree = ""; 76 | }; 77 | 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 969D928910F23F400071FD44 /* AddressBook.framework */, 81 | 08FB779EFE84155DC02AAC07 /* Foundation.framework */, 82 | ); 83 | name = "External Frameworks and Libraries"; 84 | sourceTree = ""; 85 | }; 86 | 1AB674ADFE9D54B511CA2CBB /* Products */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 8DD76FA10486AA7600D96B5E /* aboo */, 90 | ); 91 | name = Products; 92 | sourceTree = ""; 93 | }; 94 | 969D92AB10F240270071FD44 /* RegexKitLite-3.3 */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 969D92B110F240650071FD44 /* License.rtf */, 98 | 969D92B210F240650071FD44 /* RegexKitLite.html */, 99 | 969D91EE10F23BFB0071FD44 /* RegexKitLite.h */, 100 | 969D91EF10F23BFB0071FD44 /* RegexKitLite.m */, 101 | ); 102 | name = "RegexKitLite-3.3"; 103 | sourceTree = ""; 104 | }; 105 | C6859EA2029092E104C91782 /* Documentation */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | C6859EA3029092ED04C91782 /* aboo.1 */, 109 | ); 110 | name = Documentation; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | 8DD76F960486AA7600D96B5E /* aboo */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "aboo" */; 119 | buildPhases = ( 120 | 8DD76F990486AA7600D96B5E /* Sources */, 121 | 8DD76F9B0486AA7600D96B5E /* Frameworks */, 122 | 8DD76F9E0486AA7600D96B5E /* CopyFiles */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = aboo; 129 | productInstallPath = "$(HOME)/bin"; 130 | productName = aboo; 131 | productReference = 8DD76FA10486AA7600D96B5E /* aboo */; 132 | productType = "com.apple.product-type.tool"; 133 | }; 134 | /* End PBXNativeTarget section */ 135 | 136 | /* Begin PBXProject section */ 137 | 08FB7793FE84155DC02AAC07 /* Project object */ = { 138 | isa = PBXProject; 139 | buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "aboo" */; 140 | compatibilityVersion = "Xcode 3.1"; 141 | hasScannedForEncodings = 1; 142 | mainGroup = 08FB7794FE84155DC02AAC07 /* aboo */; 143 | projectDirPath = ""; 144 | projectRoot = ""; 145 | targets = ( 146 | 8DD76F960486AA7600D96B5E /* aboo */, 147 | ); 148 | }; 149 | /* End PBXProject section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | 8DD76F990486AA7600D96B5E /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | 8DD76F9A0486AA7600D96B5E /* aboo.m in Sources */, 157 | 969D91F010F23BFB0071FD44 /* RegexKitLite.m in Sources */, 158 | ); 159 | runOnlyForDeploymentPostprocessing = 0; 160 | }; 161 | /* End PBXSourcesBuildPhase section */ 162 | 163 | /* Begin XCBuildConfiguration section */ 164 | 1DEB927508733DD40010E9CD /* Debug */ = { 165 | isa = XCBuildConfiguration; 166 | buildSettings = { 167 | ALWAYS_SEARCH_USER_PATHS = NO; 168 | COPY_PHASE_STRIP = NO; 169 | GCC_DYNAMIC_NO_PIC = NO; 170 | GCC_ENABLE_FIX_AND_CONTINUE = YES; 171 | GCC_MODEL_TUNING = G5; 172 | GCC_OPTIMIZATION_LEVEL = 0; 173 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 174 | GCC_PREFIX_HEADER = aboo_Prefix.pch; 175 | INSTALL_PATH = /usr/local/bin; 176 | PRODUCT_NAME = aboo; 177 | }; 178 | name = Debug; 179 | }; 180 | 1DEB927608733DD40010E9CD /* Release */ = { 181 | isa = XCBuildConfiguration; 182 | buildSettings = { 183 | ALWAYS_SEARCH_USER_PATHS = NO; 184 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 185 | GCC_MODEL_TUNING = G5; 186 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 187 | GCC_PREFIX_HEADER = aboo_Prefix.pch; 188 | INSTALL_PATH = /usr/local/bin; 189 | PRODUCT_NAME = aboo; 190 | }; 191 | name = Release; 192 | }; 193 | 1DEB927908733DD40010E9CD /* Debug */ = { 194 | isa = XCBuildConfiguration; 195 | buildSettings = { 196 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 197 | GCC_C_LANGUAGE_STANDARD = gnu99; 198 | GCC_OPTIMIZATION_LEVEL = 0; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 200 | GCC_WARN_UNUSED_VARIABLE = YES; 201 | ONLY_ACTIVE_ARCH = YES; 202 | OTHER_LDFLAGS = "-licucore"; 203 | PREBINDING = NO; 204 | SDKROOT = macosx10.6; 205 | }; 206 | name = Debug; 207 | }; 208 | 1DEB927A08733DD40010E9CD /* Release */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 212 | GCC_C_LANGUAGE_STANDARD = gnu99; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 214 | GCC_WARN_UNUSED_VARIABLE = YES; 215 | PREBINDING = NO; 216 | SDKROOT = macosx10.6; 217 | }; 218 | name = Release; 219 | }; 220 | /* End XCBuildConfiguration section */ 221 | 222 | /* Begin XCConfigurationList section */ 223 | 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "aboo" */ = { 224 | isa = XCConfigurationList; 225 | buildConfigurations = ( 226 | 1DEB927508733DD40010E9CD /* Debug */, 227 | 1DEB927608733DD40010E9CD /* Release */, 228 | ); 229 | defaultConfigurationIsVisible = 0; 230 | defaultConfigurationName = Release; 231 | }; 232 | 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "aboo" */ = { 233 | isa = XCConfigurationList; 234 | buildConfigurations = ( 235 | 1DEB927908733DD40010E9CD /* Debug */, 236 | 1DEB927A08733DD40010E9CD /* Release */, 237 | ); 238 | defaultConfigurationIsVisible = 0; 239 | defaultConfigurationName = Release; 240 | }; 241 | /* End XCConfigurationList section */ 242 | }; 243 | rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; 244 | } 245 | -------------------------------------------------------------------------------- /RegexKitLite.h: -------------------------------------------------------------------------------- 1 | // 2 | // RegexKitLite.h 3 | // http://regexkit.sourceforge.net/ 4 | // Licensed under the terms of the BSD License, as specified below. 5 | // 6 | 7 | /* 8 | Copyright (c) 2008-2009, John Engelhart 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | * Neither the name of the Zang Industries nor the names of its 23 | contributors may be used to endorse or promote products derived from 24 | this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 32 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #ifdef __OBJC__ 40 | #import 41 | #import 42 | #import 43 | #import 44 | #import 45 | #endif // __OBJC__ 46 | 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #ifdef __cplusplus 54 | extern "C" { 55 | #endif 56 | 57 | #ifndef REGEXKITLITE_VERSION_DEFINED 58 | #define REGEXKITLITE_VERSION_DEFINED 59 | 60 | #define _RKL__STRINGIFY(b) #b 61 | #define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a) 62 | #define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b) 63 | #define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b) 64 | 65 | #define REGEXKITLITE_VERSION_MAJOR 3 66 | #define REGEXKITLITE_VERSION_MINOR 3 67 | 68 | #define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR) 69 | #define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING 70 | 71 | #endif // REGEXKITLITE_VERSION_DEFINED 72 | 73 | // For Mac OS X < 10.5. 74 | #ifndef NSINTEGER_DEFINED 75 | #define NSINTEGER_DEFINED 76 | #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 77 | typedef long NSInteger; 78 | typedef unsigned long NSUInteger; 79 | #define NSIntegerMin LONG_MIN 80 | #define NSIntegerMax LONG_MAX 81 | #define NSUIntegerMax ULONG_MAX 82 | #else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 83 | typedef int NSInteger; 84 | typedef unsigned int NSUInteger; 85 | #define NSIntegerMin INT_MIN 86 | #define NSIntegerMax INT_MAX 87 | #define NSUIntegerMax UINT_MAX 88 | #endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 89 | #endif // NSINTEGER_DEFINED 90 | 91 | #ifndef RKLREGEXOPTIONS_DEFINED 92 | #define RKLREGEXOPTIONS_DEFINED 93 | 94 | // These must be idential to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html 95 | enum { 96 | RKLNoOptions = 0, 97 | RKLCaseless = 2, 98 | RKLComments = 4, 99 | RKLDotAll = 32, 100 | RKLMultiline = 8, 101 | RKLUnicodeWordBoundaries = 256 102 | }; 103 | typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type. 104 | 105 | #endif // RKLREGEXOPTIONS_DEFINED 106 | 107 | #ifndef _REGEXKITLITE_H_ 108 | #define _REGEXKITLITE_H_ 109 | 110 | #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465) 111 | #define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) 112 | #else 113 | #define RKL_DEPRECATED_ATTRIBUTE 114 | #endif 115 | 116 | // This requires a few levels of rewriting to get the desired results. 117 | #define _RKL_CONCAT_2(c,d) c ## d 118 | #define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b) 119 | 120 | #ifdef RKL_PREPEND_TO_METHODS 121 | #define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x) 122 | #else // RKL_PREPEND_TO_METHODS 123 | #define RKL_METHOD_PREPEND(x) x 124 | #endif // RKL_PREPEND_TO_METHODS 125 | 126 | // If it looks like low memory notifications might be available, add code to register and respond to them. 127 | // This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for, 128 | // UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym(). 129 | #if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0)) 130 | #define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1 131 | #endif 132 | 133 | #ifdef __OBJC__ 134 | 135 | // NSException exception name. 136 | extern NSString * const RKLICURegexException; 137 | 138 | // NSError error domains and user info keys. 139 | extern NSString * const RKLICURegexErrorDomain; 140 | 141 | extern NSString * const RKLICURegexErrorCodeErrorKey; 142 | extern NSString * const RKLICURegexErrorNameErrorKey; 143 | extern NSString * const RKLICURegexLineErrorKey; 144 | extern NSString * const RKLICURegexOffsetErrorKey; 145 | extern NSString * const RKLICURegexPreContextErrorKey; 146 | extern NSString * const RKLICURegexPostContextErrorKey; 147 | extern NSString * const RKLICURegexRegexErrorKey; 148 | extern NSString * const RKLICURegexRegexOptionsErrorKey; 149 | 150 | @interface NSString (RegexKitLiteAdditions) 151 | 152 | + (void)RKL_METHOD_PREPEND(clearStringCache); 153 | 154 | // Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857. 155 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE; 156 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE; 157 | 158 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex; 159 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range; 160 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 161 | 162 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex; 163 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range; 164 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error; 165 | 166 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex; 167 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture; 168 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range; 169 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 170 | 171 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex; 172 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture; 173 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range; 174 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 175 | 176 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; 177 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; 178 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; 179 | 180 | //// 181 | 182 | - (NSInteger)RKL_METHOD_PREPEND(captureCount); 183 | - (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error; 184 | 185 | - (BOOL)RKL_METHOD_PREPEND(isRegexValid); 186 | - (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error; 187 | 188 | - (void)RKL_METHOD_PREPEND(flushCachedRegexData); 189 | 190 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex; 191 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture; 192 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 193 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; 194 | 195 | 196 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex; 197 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 198 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 199 | 200 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex; 201 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; 202 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; 203 | 204 | @end 205 | 206 | @interface NSMutableString (RegexKitLiteAdditions) 207 | 208 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; 209 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; 210 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; 211 | 212 | @end 213 | 214 | #endif // __OBJC__ 215 | 216 | #endif // _REGEXKITLITE_H_ 217 | 218 | #ifdef __cplusplus 219 | } // extern "C" 220 | #endif 221 | -------------------------------------------------------------------------------- /aboo.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "RegexKitLite.h" 4 | #include 5 | 6 | #define OPTION_FORMAT " %s %s\t%s\n" /* Ausgabeformat fuer usage() */ 7 | 8 | void usage(); 9 | void print_person(ABPerson *person); 10 | void print_person_phone(ABPerson *person); 11 | void print_person_vcf(ABPerson *person); 12 | void print_person_ics(ABPerson *person); 13 | void print_person_yml(ABPerson *person); 14 | void print_person_mutt(ABPerson *person); 15 | BOOL match_person_regex(ABPerson *person, NSString *pattern); 16 | BOOL match_regex(NSString *text, NSString *pattern); 17 | void import_data(NSData *inputData); 18 | void update_data(NSData *inputData); 19 | ABPerson *find_person(ABPerson *person); 20 | NSArray *read_people(NSData *inputData); 21 | 22 | int main (int argc, const char * argv[]) { 23 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 24 | 25 | // getopt 26 | int ch; 27 | char *optSearchTerm = NULL; 28 | BOOL shouldSearchTerm = NO; 29 | BOOL shouldOutputVcf = NO; 30 | BOOL shouldOutputIcs = NO; 31 | BOOL shouldOutputYml = NO; 32 | BOOL shouldOutputMutt = NO; 33 | BOOL shouldImportVcf = NO; 34 | BOOL shouldOutputPhone = NO; 35 | 36 | while ((ch = getopt(argc, (char * const *) argv, "hfs:mvpyb")) != -1) 37 | { 38 | switch(ch) 39 | { 40 | case 'b': 41 | shouldOutputIcs = YES; 42 | break; 43 | case 's': 44 | optSearchTerm = optarg; 45 | shouldSearchTerm = YES; 46 | break; 47 | case 'm': 48 | shouldOutputMutt = YES; 49 | break; 50 | case 'v': 51 | shouldOutputVcf = YES; 52 | break; 53 | case 'y': 54 | shouldOutputYml = YES; 55 | break; 56 | case 'p': 57 | shouldOutputPhone = YES; 58 | break; 59 | case 'h': 60 | usage(); 61 | break; 62 | } 63 | } 64 | argc -= optind; 65 | argv += optind; 66 | 67 | // getting address book and the people array 68 | ABAddressBook *abook = [ABAddressBook sharedAddressBook]; 69 | NSArray *people = [abook people]; 70 | NSEnumerator *enumerator = [people objectEnumerator]; 71 | ABPerson *person; 72 | NSString *regex = @""; 73 | if(optSearchTerm != NULL) 74 | { 75 | regex = [[[NSString alloc] initWithUTF8String:optSearchTerm] stringByReplacingOccurrencesOfString:@" " withString:@"\\s"]; 76 | } 77 | 78 | if(shouldOutputYml) printf("--- # YAML 1.0\n"); 79 | if(shouldOutputMutt) printf("Search term: '%s'\n", [regex UTF8String]); 80 | if(shouldOutputIcs) printf("BEGIN:VCALENDAR\nVERSION:2.0\nX-WR-CALNAME:Birthdays\nX-WR-CALDESC:created by aboo\nX-WR-TIMEZONE:Europe/Berlin\nCALSCALE:GREGORIAN\n"); 81 | 82 | while((person = [enumerator nextObject])) 83 | { 84 | BOOL recordMatches = NO; 85 | if (shouldSearchTerm && match_person_regex(person, regex)) 86 | { 87 | recordMatches = YES; 88 | } 89 | 90 | if(!shouldSearchTerm || recordMatches) 91 | { 92 | if (shouldOutputPhone) 93 | { 94 | print_person_phone(person); 95 | } 96 | else if(shouldOutputVcf) 97 | { 98 | print_person_vcf(person); 99 | } 100 | else if(shouldOutputIcs) 101 | { 102 | print_person_ics(person); 103 | } 104 | else if(shouldOutputYml) 105 | { 106 | print_person_yml(person); 107 | } 108 | else if(shouldOutputMutt) 109 | { 110 | print_person_mutt(person); 111 | } 112 | else 113 | { 114 | print_person(person); 115 | } 116 | } 117 | } 118 | 119 | if(shouldOutputIcs) printf("END:VCALENDAR\n"); 120 | 121 | [pool release]; 122 | return 0; 123 | } 124 | BOOL match_person_regex(ABPerson *person, NSString *pattern) 125 | { 126 | NSString *lastName = [person valueForProperty:kABLastNameProperty]; 127 | NSString *firstName = [person valueForProperty:kABFirstNameProperty]; 128 | NSString *nickName = [person valueForProperty:kABNicknameProperty]; 129 | NSString *company = [person valueForProperty:kABOrganizationProperty]; 130 | ABMultiValue *email = [person valueForProperty:kABEmailProperty]; 131 | NSString *primaryEmail = [email valueAtIndex:[email indexForIdentifier:[email primaryIdentifier]]]; 132 | NSString *note = [person valueForProperty:kABNoteProperty]; 133 | 134 | if(match_regex(nickName, pattern) || 135 | match_regex(lastName, pattern) || 136 | match_regex(firstName, pattern) || 137 | match_regex(primaryEmail, pattern) || 138 | match_regex(company, pattern) || 139 | match_regex(note, pattern)) 140 | return YES; 141 | else 142 | return NO; 143 | } 144 | 145 | BOOL match_regex(NSString *text, NSString *pattern) 146 | { 147 | NSRange range = NSMakeRange(0, [text length]); 148 | NSError *error = NULL; 149 | NSString *match = [text stringByMatching:pattern options:RKLCaseless inRange:range capture:0 error:&error]; 150 | 151 | if(text != NULL && match != NULL) 152 | return YES; 153 | else 154 | return NO; 155 | } 156 | 157 | void print_person_phone(ABPerson *person) 158 | { 159 | NSString *lastName = [person valueForProperty:kABLastNameProperty]; 160 | NSString *firstName = [person valueForProperty:kABFirstNameProperty]; 161 | NSString *company = [person valueForProperty:kABOrganizationProperty]; 162 | NSString *formattedOutput; 163 | if (lastName != nil && firstName != nil) 164 | formattedOutput = [[NSString alloc] initWithFormat:@"%@ %@", firstName, lastName]; 165 | else if (company != nil) 166 | formattedOutput = [[NSString alloc] initWithFormat:@"%@", company]; 167 | else 168 | formattedOutput = [[NSString alloc] initWithString:@"Unknown"]; 169 | 170 | ABMultiValue *phone = [person valueForProperty:kABPhoneProperty]; 171 | NSString *primaryPhone = [phone valueAtIndex:[phone indexForIdentifier:[phone primaryIdentifier]]]; 172 | if(primaryPhone != nil) 173 | { 174 | formattedOutput = [formattedOutput stringByAppendingFormat:@": %@", primaryPhone]; 175 | printf("%s\n", [formattedOutput UTF8String]); 176 | } 177 | } 178 | 179 | void print_person_ics(ABPerson *person) 180 | { 181 | NSString *ics = @""; 182 | NSDate *bday = [person valueForProperty:kABBirthdayProperty]; 183 | 184 | if(!bday) return; 185 | 186 | NSString *bdayString = [bday descriptionWithCalendarFormat:@"%Y%m%d" timeZone:nil locale:nil]; 187 | NSString *dayAfterString = [[bday addTimeInterval:60*60*24] descriptionWithCalendarFormat:@"%Y%m%d" timeZone:nil locale:nil]; 188 | 189 | ics = [ics stringByAppendingString:@"BEGIN:VEVENT\n"]; 190 | ics = [ics stringByAppendingFormat:@"DTSTART;VALUE=DATE:%s\n", [bdayString UTF8String]]; 191 | ics = [ics stringByAppendingFormat:@"DTEND;VALUE=DATE:%s\n", [dayAfterString UTF8String]]; 192 | ics = [ics stringByAppendingFormat:@"SUMMARY:%s %s\n", 193 | [[person valueForProperty:kABFirstNameProperty] UTF8String], 194 | [[person valueForProperty:kABLastNameProperty] UTF8String] ]; 195 | ics = [ics stringByAppendingFormat:@"SEQUENCE:%i\n", 3]; 196 | ics = [ics stringByAppendingString:@"RRULE:FREQ=YEARLY;INTERVAL=1\n"]; 197 | ics = [ics stringByAppendingString:@"BEGIN:VALARM\nTRIGGER:-P1D\nDESCRIPTION:Birthday\nACTION:DISPLAY\nEND:VALARM\nEND:VEVENT\n"]; 198 | 199 | printf("%s", [ics UTF8String]); 200 | } 201 | 202 | void print_person_vcf(ABPerson *person) 203 | { 204 | NSData *vCardData = [person vCardRepresentation]; 205 | NSString *vCardString = [[NSString alloc] initWithData:vCardData encoding:NSUTF8StringEncoding]; 206 | if(vCardString == nil) 207 | { 208 | [vCardString release]; 209 | vCardString = [[NSString alloc] initWithData:vCardData encoding:NSUnicodeStringEncoding]; 210 | } 211 | printf("%s", [vCardString UTF8String]); 212 | [vCardString release]; 213 | } 214 | 215 | void print_person_yml(ABPerson *person) 216 | { 217 | NSArray *properties = [ABPerson properties]; 218 | NSEnumerator *it = [properties objectEnumerator]; 219 | NSString *property; 220 | 221 | printf("-\n"); 222 | 223 | while(property = [it nextObject]) 224 | { 225 | ABPropertyType type = [ABPerson typeOfProperty:property]; 226 | 227 | if(type == kABStringProperty) 228 | { 229 | NSString *string = [person valueForProperty:property]; 230 | if(string != nil) printf(" %s: %s\n", [property UTF8String], [string UTF8String]); 231 | } 232 | else if(type == kABDateProperty) 233 | { 234 | NSCalendarDate *date = [person valueForProperty:property]; 235 | if(date != nil) printf(" %s: %s\n", [property UTF8String], [[date description] UTF8String]); 236 | } 237 | else if(type == kABMultiStringProperty) 238 | { 239 | ABMultiValue *multiValue = [person valueForProperty:property]; 240 | if(multiValue != nil) 241 | { 242 | NSString *primaryIdentifier = [multiValue primaryIdentifier]; 243 | if(primaryIdentifier != nil) 244 | { 245 | NSString *primaryValue = [multiValue valueAtIndex:[multiValue indexForIdentifier:primaryIdentifier]]; 246 | if(primaryValue != nil) printf(" %s: %s\n", [property UTF8String], [primaryValue UTF8String]); 247 | } 248 | } 249 | } 250 | } 251 | } 252 | 253 | void print_person_mutt(ABPerson *person) 254 | { 255 | NSString *lastName = [person valueForProperty:kABLastNameProperty]; 256 | NSString *firstName = [person valueForProperty:kABFirstNameProperty]; 257 | ABMultiValue *email = [person valueForProperty:kABEmailProperty]; 258 | NSString *primaryEmail = [email valueAtIndex:[email indexForIdentifier:[email primaryIdentifier]]]; 259 | 260 | NSString *formattedOutput = [NSString stringWithFormat:@"%@\t%@ %@", primaryEmail, firstName, lastName]; 261 | 262 | if(primaryEmail == nil) 263 | return; /* don't output a person without mail address */ 264 | 265 | printf("%s\n", [formattedOutput UTF8String]); 266 | } 267 | 268 | void print_person(ABPerson *person) 269 | { 270 | NSString *lastName = [person valueForProperty:kABLastNameProperty]; 271 | NSString *firstName = [person valueForProperty:kABFirstNameProperty]; 272 | NSString *company = [person valueForProperty:kABOrganizationProperty]; 273 | ABMultiValue *phone = [person valueForProperty:kABPhoneProperty]; 274 | ABMultiValue *email = [person valueForProperty:kABEmailProperty]; 275 | 276 | NSString *primaryPhone = [phone valueAtIndex:[phone indexForIdentifier:[phone primaryIdentifier]]]; 277 | NSString *primaryEmail = [email valueAtIndex:[email indexForIdentifier:[email primaryIdentifier]]]; 278 | 279 | NSString *formattedOutput; 280 | if (lastName != nil && firstName != nil) 281 | formattedOutput = [[NSString alloc] initWithFormat:@"%@ %@", firstName, lastName]; 282 | else if (company != nil) 283 | formattedOutput = [[NSString alloc] initWithFormat:@"%@", company]; 284 | else 285 | formattedOutput = [[NSString alloc] initWithString:@"Unknown"]; 286 | 287 | if(primaryEmail != nil) 288 | { 289 | formattedOutput = [formattedOutput stringByAppendingFormat:@" <%@>", primaryEmail]; 290 | } 291 | if(primaryPhone != nil) 292 | { 293 | formattedOutput = [formattedOutput stringByAppendingFormat:@": %@", primaryPhone]; 294 | } 295 | 296 | printf("%s\n", [formattedOutput UTF8String]); 297 | } 298 | 299 | void usage() 300 | { 301 | printf("usage: %s [options]\n", "aboo"); 302 | printf(OPTION_FORMAT, "-s", "", "search for term in first-, last- and nickname"); 303 | printf(OPTION_FORMAT, "-p", "\t\t", "Phone number-only output"); 304 | printf(OPTION_FORMAT, "-v", "\t\t", "vCard 3.0 output"); 305 | printf(OPTION_FORMAT, "-y", "\t\t", "YAML 1.0 output"); 306 | printf(OPTION_FORMAT, "-b", "\t\t", "ics birthday calendar output"); 307 | printf(OPTION_FORMAT, "-m", "\t\t", "Mutt address book output"); 308 | printf(OPTION_FORMAT, "-h", "\t\t", "this help screen"); 309 | exit(1); 310 | } 311 | 312 | -------------------------------------------------------------------------------- /aboo.xcodeproj/chneeb.pbxuser: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | 08FB7793FE84155DC02AAC07 /* Project object */ = { 4 | activeBuildConfigurationName = Debug; 5 | activeExecutable = 969D91DB10F23AA80071FD44 /* aboo */; 6 | activeTarget = 8DD76F960486AA7600D96B5E /* aboo */; 7 | addToTargets = ( 8 | 8DD76F960486AA7600D96B5E /* aboo */, 9 | ); 10 | codeSenseManager = 969D91E710F23AB10071FD44 /* Code sense */; 11 | executables = ( 12 | 969D91DB10F23AA80071FD44 /* aboo */, 13 | ); 14 | perUserDictionary = { 15 | PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { 16 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 17 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 18 | PBXFileTableDataSourceColumnWidthsKey = ( 19 | 20, 20 | 583, 21 | 20, 22 | 48, 23 | 43, 24 | 43, 25 | 20, 26 | ); 27 | PBXFileTableDataSourceColumnsKey = ( 28 | PBXFileDataSource_FiletypeID, 29 | PBXFileDataSource_Filename_ColumnID, 30 | PBXFileDataSource_Built_ColumnID, 31 | PBXFileDataSource_ObjectSize_ColumnID, 32 | PBXFileDataSource_Errors_ColumnID, 33 | PBXFileDataSource_Warnings_ColumnID, 34 | PBXFileDataSource_Target_ColumnID, 35 | ); 36 | }; 37 | PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { 38 | PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; 39 | PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; 40 | PBXFileTableDataSourceColumnWidthsKey = ( 41 | 20, 42 | 473, 43 | 60, 44 | 20, 45 | 48, 46 | 43, 47 | 43, 48 | ); 49 | PBXFileTableDataSourceColumnsKey = ( 50 | PBXFileDataSource_FiletypeID, 51 | PBXFileDataSource_Filename_ColumnID, 52 | PBXTargetDataSource_PrimaryAttribute, 53 | PBXFileDataSource_Built_ColumnID, 54 | PBXFileDataSource_ObjectSize_ColumnID, 55 | PBXFileDataSource_Errors_ColumnID, 56 | PBXFileDataSource_Warnings_ColumnID, 57 | ); 58 | }; 59 | PBXPerProjectTemplateStateSaveDate = 284397986; 60 | PBXWorkspaceStateSaveDate = 284397986; 61 | }; 62 | perUserProjectItems = { 63 | 969584B710F397B100978746 /* XCBuildMessageTextBookmark */ = 969584B710F397B100978746 /* XCBuildMessageTextBookmark */; 64 | 969584B810F397B100978746 /* PBXTextBookmark */ = 969584B810F397B100978746 /* PBXTextBookmark */; 65 | 969584BE10F397EA00978746 /* XCBuildMessageTextBookmark */ = 969584BE10F397EA00978746 /* XCBuildMessageTextBookmark */; 66 | 969584BF10F397EA00978746 /* PBXTextBookmark */ = 969584BF10F397EA00978746 /* PBXTextBookmark */; 67 | 969584C010F397EE00978746 /* XCBuildMessageTextBookmark */ = 969584C010F397EE00978746 /* XCBuildMessageTextBookmark */; 68 | 969584C110F397EE00978746 /* PBXTextBookmark */ = 969584C110F397EE00978746 /* PBXTextBookmark */; 69 | 969584C510F39B5900978746 /* PBXTextBookmark */ = 969584C510F39B5900978746 /* PBXTextBookmark */; 70 | 969584C810F3A41400978746 /* XCBuildMessageTextBookmark */ = 969584C810F3A41400978746 /* XCBuildMessageTextBookmark */; 71 | 969584C910F3A41400978746 /* PBXTextBookmark */ = 969584C910F3A41400978746 /* PBXTextBookmark */; 72 | 969584CD10F3A43000978746 /* XCBuildMessageTextBookmark */ = 969584CD10F3A43000978746 /* XCBuildMessageTextBookmark */; 73 | 969584CE10F3A43000978746 /* PBXTextBookmark */ = 969584CE10F3A43000978746 /* PBXTextBookmark */; 74 | 969584D310F3A45800978746 /* XCBuildMessageTextBookmark */ = 969584D310F3A45800978746 /* XCBuildMessageTextBookmark */; 75 | 969584D410F3A45800978746 /* PBXTextBookmark */ = 969584D410F3A45800978746 /* PBXTextBookmark */; 76 | 969584D910F3A4F800978746 /* PBXTextBookmark */ = 969584D910F3A4F800978746 /* PBXTextBookmark */; 77 | 969584DC10F3A54D00978746 /* PBXTextBookmark */ = 969584DC10F3A54D00978746 /* PBXTextBookmark */; 78 | 969584DF10F3A6B200978746 /* PBXTextBookmark */ = 969584DF10F3A6B200978746 /* PBXTextBookmark */; 79 | 969584E610F3BBA000978746 /* PBXTextBookmark */ = 969584E610F3BBA000978746 /* PBXTextBookmark */; 80 | 969584EA10F3BCB300978746 /* XCBuildMessageTextBookmark */ = 969584EA10F3BCB300978746 /* XCBuildMessageTextBookmark */; 81 | 969584EB10F3BCB300978746 /* PBXTextBookmark */ = 969584EB10F3BCB300978746 /* PBXTextBookmark */; 82 | 969584EE10F3BCBE00978746 /* XCBuildMessageTextBookmark */ = 969584EE10F3BCBE00978746 /* XCBuildMessageTextBookmark */; 83 | 969584EF10F3BCBE00978746 /* PBXTextBookmark */ = 969584EF10F3BCBE00978746 /* PBXTextBookmark */; 84 | 969584F610F3BF6B00978746 /* PBXTextBookmark */ = 969584F610F3BF6B00978746 /* PBXTextBookmark */; 85 | 969584F910F3BFB300978746 /* PBXTextBookmark */ = 969584F910F3BFB300978746 /* PBXTextBookmark */; 86 | 969584FC10F3C16100978746 /* PBXTextBookmark */ = 969584FC10F3C16100978746 /* PBXTextBookmark */; 87 | 969584FF10F3C2A500978746 /* PBXTextBookmark */ = 969584FF10F3C2A500978746 /* PBXTextBookmark */; 88 | 9695850010F3C2A500978746 /* PBXTextBookmark */ = 9695850010F3C2A500978746 /* PBXTextBookmark */; 89 | 9695850310F3C33300978746 /* PBXTextBookmark */ = 9695850310F3C33300978746 /* PBXTextBookmark */; 90 | 9695850610F3C3E700978746 /* PBXTextBookmark */ = 9695850610F3C3E700978746 /* PBXTextBookmark */; 91 | 9695850910F3C46A00978746 /* PBXTextBookmark */ = 9695850910F3C46A00978746 /* PBXTextBookmark */; 92 | 9695850C10F3C50500978746 /* PBXTextBookmark */ = 9695850C10F3C50500978746 /* PBXTextBookmark */; 93 | 9695850F10F3C54D00978746 /* PBXTextBookmark */ = 9695850F10F3C54D00978746 /* PBXTextBookmark */; 94 | 9695851210F3C59B00978746 /* PBXTextBookmark */ = 9695851210F3C59B00978746 /* PBXTextBookmark */; 95 | 9695851510F3C5DD00978746 /* PBXTextBookmark */ = 9695851510F3C5DD00978746 /* PBXTextBookmark */; 96 | 9695851810F3C63900978746 /* PBXTextBookmark */ = 9695851810F3C63900978746 /* PBXTextBookmark */; 97 | 9695852110F3C65000978746 /* PBXTextBookmark */ = 9695852110F3C65000978746 /* PBXTextBookmark */; 98 | 9695852410F3C66800978746 /* PBXTextBookmark */ = 9695852410F3C66800978746 /* PBXTextBookmark */; 99 | 9695852710F3C7CC00978746 /* PBXTextBookmark */ = 9695852710F3C7CC00978746 /* PBXTextBookmark */; 100 | 9695852A10F3C7EE00978746 /* PBXTextBookmark */ = 9695852A10F3C7EE00978746 /* PBXTextBookmark */; 101 | 9695853110F3C84500978746 /* PBXTextBookmark */ = 9695853110F3C84500978746 /* PBXTextBookmark */; 102 | 9695853410F3C86400978746 /* PBXTextBookmark */ = 9695853410F3C86400978746 /* PBXTextBookmark */; 103 | 9695853710F3C8C500978746 /* PBXTextBookmark */ = 9695853710F3C8C500978746 /* PBXTextBookmark */; 104 | 9695853E10F3CA1300978746 /* PBXTextBookmark */ = 9695853E10F3CA1300978746 /* PBXTextBookmark */; 105 | 9695854110F3CA7300978746 /* PBXTextBookmark */ = 9695854110F3CA7300978746 /* PBXTextBookmark */; 106 | 9695854410F3CB7E00978746 /* PBXTextBookmark */ = 9695854410F3CB7E00978746 /* PBXTextBookmark */; 107 | 9695854710F3CB9E00978746 /* PBXTextBookmark */ = 9695854710F3CB9E00978746 /* PBXTextBookmark */; 108 | 9695854A10F3CDD000978746 /* XCBuildMessageTextBookmark */ = 9695854A10F3CDD000978746 /* XCBuildMessageTextBookmark */; 109 | 9695854B10F3CDD000978746 /* PBXTextBookmark */ = 9695854B10F3CDD000978746 /* PBXTextBookmark */; 110 | 9695855410F3CE9D00978746 /* XCBuildMessageTextBookmark */ = 9695855410F3CE9D00978746 /* XCBuildMessageTextBookmark */; 111 | 9695855510F3CE9D00978746 /* PBXTextBookmark */ = 9695855510F3CE9D00978746 /* PBXTextBookmark */; 112 | 9695855810F3CED900978746 /* PBXTextBookmark */ = 9695855810F3CED900978746 /* PBXTextBookmark */; 113 | 9695855B10F3CF0200978746 /* PBXTextBookmark */ = 9695855B10F3CF0200978746 /* PBXTextBookmark */; 114 | 9695855E10F3CF5E00978746 /* PBXTextBookmark */ = 9695855E10F3CF5E00978746 /* PBXTextBookmark */; 115 | 9695856110F3D07B00978746 /* PBXTextBookmark */ = 9695856110F3D07B00978746 /* PBXTextBookmark */; 116 | 969D92B510F240D40071FD44 = 969D92B510F240D40071FD44 /* PBXTextBookmark */; 117 | 969EE52810F26EFA00A8A873 = 969EE52810F26EFA00A8A873 /* PBXTextBookmark */; 118 | 96E1FE7E10F243F20052FC4A = 96E1FE7E10F243F20052FC4A /* PBXTextBookmark */; 119 | }; 120 | sourceControlManager = 969D91E610F23AB10071FD44 /* Source Control */; 121 | userBuildSettings = { 122 | }; 123 | }; 124 | 08FB7796FE84155DC02AAC07 /* aboo.m */ = { 125 | uiCtxt = { 126 | sepNavIntBoundsRect = "{{0, 0}, {761, 3679}}"; 127 | sepNavSelRange = "{1083, 0}"; 128 | sepNavVisRange = "{366, 1092}"; 129 | sepNavWindowFrame = "{{583, 117}, {978, 786}}"; 130 | }; 131 | }; 132 | 8DD76F960486AA7600D96B5E /* aboo */ = { 133 | activeExec = 0; 134 | executables = ( 135 | 969D91DB10F23AA80071FD44 /* aboo */, 136 | ); 137 | }; 138 | 969584B710F397B100978746 /* XCBuildMessageTextBookmark */ = { 139 | isa = PBXTextBookmark; 140 | comments = "Expected ',' or ';' before ')' token"; 141 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 142 | fallbackIsa = XCBuildMessageTextBookmark; 143 | rLen = 0; 144 | rLoc = 214; 145 | rType = 1; 146 | }; 147 | 969584B810F397B100978746 /* PBXTextBookmark */ = { 148 | isa = PBXTextBookmark; 149 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 150 | name = "aboo.m: 357"; 151 | rLen = 0; 152 | rLoc = 6188; 153 | rType = 0; 154 | vrLen = 354; 155 | vrLoc = 10089; 156 | }; 157 | 969584BE10F397EA00978746 /* XCBuildMessageTextBookmark */ = { 158 | isa = PBXTextBookmark; 159 | comments = "Previous implicit declaration of 'print_person_mutt' was here"; 160 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 161 | fallbackIsa = XCBuildMessageTextBookmark; 162 | rLen = 1; 163 | rLoc = 101; 164 | rType = 1; 165 | }; 166 | 969584BF10F397EA00978746 /* PBXTextBookmark */ = { 167 | isa = PBXTextBookmark; 168 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 169 | name = "aboo.m: 142"; 170 | rLen = 0; 171 | rLoc = 2631; 172 | rType = 0; 173 | vrLen = 248; 174 | vrLoc = 3133; 175 | }; 176 | 969584C010F397EE00978746 /* XCBuildMessageTextBookmark */ = { 177 | isa = PBXTextBookmark; 178 | comments = "Conflicting types for 'print_person_mutt'"; 179 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 180 | fallbackIsa = XCBuildMessageTextBookmark; 181 | rLen = 1; 182 | rLoc = 215; 183 | rType = 1; 184 | }; 185 | 969584C110F397EE00978746 /* PBXTextBookmark */ = { 186 | isa = PBXTextBookmark; 187 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 188 | name = "aboo.m: 388"; 189 | rLen = 0; 190 | rLoc = 6188; 191 | rType = 0; 192 | vrLen = 1471; 193 | vrLoc = 10689; 194 | }; 195 | 969584C510F39B5900978746 /* PBXTextBookmark */ = { 196 | isa = PBXTextBookmark; 197 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 198 | name = "aboo.m: 138"; 199 | rLen = 0; 200 | rLoc = 2597; 201 | rType = 0; 202 | vrLen = 956; 203 | vrLoc = 2433; 204 | }; 205 | 969584C810F3A41400978746 /* XCBuildMessageTextBookmark */ = { 206 | isa = PBXTextBookmark; 207 | comments = "'pattern' undeclared (first use in this function)"; 208 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 209 | fallbackIsa = XCBuildMessageTextBookmark; 210 | rLen = 0; 211 | rLoc = 161; 212 | rType = 1; 213 | }; 214 | 969584C910F3A41400978746 /* PBXTextBookmark */ = { 215 | isa = PBXTextBookmark; 216 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 217 | name = "aboo.m: 224"; 218 | rLen = 0; 219 | rLoc = 4631; 220 | rType = 0; 221 | vrLen = 450; 222 | vrLoc = 6256; 223 | }; 224 | 969584CD10F3A43000978746 /* XCBuildMessageTextBookmark */ = { 225 | isa = PBXTextBookmark; 226 | comments = "'source' undeclared (first use in this function)"; 227 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 228 | fallbackIsa = XCBuildMessageTextBookmark; 229 | rLen = 0; 230 | rLoc = 161; 231 | rType = 1; 232 | }; 233 | 969584CE10F3A43000978746 /* PBXTextBookmark */ = { 234 | isa = PBXTextBookmark; 235 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 236 | name = "aboo.m: 242"; 237 | rLen = 0; 238 | rLoc = 4631; 239 | rType = 0; 240 | vrLen = 175; 241 | vrLoc = 6710; 242 | }; 243 | 969584D310F3A45800978746 /* XCBuildMessageTextBookmark */ = { 244 | isa = PBXTextBookmark; 245 | comments = "'source' undeclared (first use in this function)"; 246 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 247 | fallbackIsa = XCBuildMessageTextBookmark; 248 | rLen = 0; 249 | rLoc = 161; 250 | rType = 1; 251 | }; 252 | 969584D410F3A45800978746 /* PBXTextBookmark */ = { 253 | isa = PBXTextBookmark; 254 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 255 | name = "aboo.m: 126"; 256 | rLen = 0; 257 | rLoc = 2337; 258 | rType = 0; 259 | vrLen = 1269; 260 | vrLoc = 2197; 261 | }; 262 | 969584D910F3A4F800978746 /* PBXTextBookmark */ = { 263 | isa = PBXTextBookmark; 264 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 265 | name = "aboo.m: 125"; 266 | rLen = 0; 267 | rLoc = 2320; 268 | rType = 0; 269 | vrLen = 1263; 270 | vrLoc = 2197; 271 | }; 272 | 969584DC10F3A54D00978746 /* PBXTextBookmark */ = { 273 | isa = PBXTextBookmark; 274 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 275 | name = "aboo.m: 124"; 276 | rLen = 0; 277 | rLoc = 2320; 278 | rType = 0; 279 | vrLen = 832; 280 | vrLoc = 2695; 281 | }; 282 | 969584DF10F3A6B200978746 /* PBXTextBookmark */ = { 283 | isa = PBXTextBookmark; 284 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 285 | name = "aboo.m: 113"; 286 | rLen = 0; 287 | rLoc = 2223; 288 | rType = 0; 289 | vrLen = 1053; 290 | vrLoc = 2424; 291 | }; 292 | 969584E610F3BBA000978746 /* PBXTextBookmark */ = { 293 | isa = PBXTextBookmark; 294 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 295 | name = "aboo.m: 117"; 296 | rLen = 0; 297 | rLoc = 2182; 298 | rType = 0; 299 | vrLen = 1136; 300 | vrLoc = 2443; 301 | }; 302 | 969584EA10F3BCB300978746 /* XCBuildMessageTextBookmark */ = { 303 | isa = PBXTextBookmark; 304 | comments = "'optSearchRegex' undeclared (first use in this function)"; 305 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 306 | fallbackIsa = XCBuildMessageTextBookmark; 307 | rLen = 1; 308 | rLoc = 74; 309 | rType = 1; 310 | }; 311 | 969584EB10F3BCB300978746 /* PBXTextBookmark */ = { 312 | isa = PBXTextBookmark; 313 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 314 | name = "aboo.m: 115"; 315 | rLen = 0; 316 | rLoc = 1942; 317 | rType = 0; 318 | vrLen = 468; 319 | vrLoc = 2584; 320 | }; 321 | 969584EE10F3BCBE00978746 /* XCBuildMessageTextBookmark */ = { 322 | isa = PBXTextBookmark; 323 | comments = "'optSearchRegex' undeclared (first use in this function)"; 324 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 325 | fallbackIsa = XCBuildMessageTextBookmark; 326 | rLen = 1; 327 | rLoc = 74; 328 | rType = 1; 329 | }; 330 | 969584EF10F3BCBE00978746 /* PBXTextBookmark */ = { 331 | isa = PBXTextBookmark; 332 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 333 | name = "aboo.m: 116"; 334 | rLen = 0; 335 | rLoc = 2182; 336 | rType = 0; 337 | vrLen = 1179; 338 | vrLoc = 2245; 339 | }; 340 | 969584F610F3BF6B00978746 /* PBXTextBookmark */ = { 341 | isa = PBXTextBookmark; 342 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 343 | name = "aboo.m: 104"; 344 | rLen = 0; 345 | rLoc = 2529; 346 | rType = 0; 347 | vrLen = 910; 348 | vrLoc = 1822; 349 | }; 350 | 969584F910F3BFB300978746 /* PBXTextBookmark */ = { 351 | isa = PBXTextBookmark; 352 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 353 | name = "aboo.m: 93"; 354 | rLen = 0; 355 | rLoc = 2319; 356 | rType = 0; 357 | vrLen = 1029; 358 | vrLoc = 2270; 359 | }; 360 | 969584FC10F3C16100978746 /* PBXTextBookmark */ = { 361 | isa = PBXTextBookmark; 362 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 363 | name = "aboo.m: 98"; 364 | rLen = 0; 365 | rLoc = 2344; 366 | rType = 0; 367 | vrLen = 966; 368 | vrLoc = 1910; 369 | }; 370 | 969584FF10F3C2A500978746 /* PBXTextBookmark */ = { 371 | isa = PBXTextBookmark; 372 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 373 | name = "aboo.m: 97"; 374 | rLen = 0; 375 | rLoc = 2335; 376 | rType = 0; 377 | vrLen = 966; 378 | vrLoc = 1910; 379 | }; 380 | 9695850010F3C2A500978746 /* PBXTextBookmark */ = { 381 | isa = PBXTextBookmark; 382 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 383 | name = "aboo.m: 91"; 384 | rLen = 0; 385 | rLoc = 2233; 386 | rType = 0; 387 | vrLen = 961; 388 | vrLoc = 1859; 389 | }; 390 | 9695850310F3C33300978746 /* PBXTextBookmark */ = { 391 | isa = PBXTextBookmark; 392 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 393 | name = "aboo.m: 192"; 394 | rLen = 0; 395 | rLoc = 4631; 396 | rType = 0; 397 | vrLen = 915; 398 | vrLoc = 4509; 399 | }; 400 | 9695850610F3C3E700978746 /* PBXTextBookmark */ = { 401 | isa = PBXTextBookmark; 402 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 403 | name = "aboo.m: 88"; 404 | rLen = 0; 405 | rLoc = 2182; 406 | rType = 0; 407 | vrLen = 1148; 408 | vrLoc = 1617; 409 | }; 410 | 9695850910F3C46A00978746 /* PBXTextBookmark */ = { 411 | isa = PBXTextBookmark; 412 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 413 | name = "aboo.m: 92"; 414 | rLen = 0; 415 | rLoc = 2181; 416 | rType = 0; 417 | vrLen = 1128; 418 | vrLoc = 1631; 419 | }; 420 | 9695850C10F3C50500978746 /* PBXTextBookmark */ = { 421 | isa = PBXTextBookmark; 422 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 423 | name = "aboo.m: 164"; 424 | rLen = 0; 425 | rLoc = 3513; 426 | rType = 0; 427 | vrLen = 674; 428 | vrLoc = 2948; 429 | }; 430 | 9695850F10F3C54D00978746 /* PBXTextBookmark */ = { 431 | isa = PBXTextBookmark; 432 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 433 | name = "aboo.m: 154"; 434 | rLen = 0; 435 | rLoc = 3458; 436 | rType = 0; 437 | vrLen = 765; 438 | vrLoc = 2948; 439 | }; 440 | 9695851210F3C59B00978746 /* PBXTextBookmark */ = { 441 | isa = PBXTextBookmark; 442 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 443 | name = "aboo.m: 145"; 444 | rLen = 0; 445 | rLoc = 3483; 446 | rType = 0; 447 | vrLen = 974; 448 | vrLoc = 2851; 449 | }; 450 | 9695851510F3C5DD00978746 /* PBXTextBookmark */ = { 451 | isa = PBXTextBookmark; 452 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 453 | name = "aboo.m: 142"; 454 | rLen = 0; 455 | rLoc = 3493; 456 | rType = 0; 457 | vrLen = 1147; 458 | vrLoc = 2795; 459 | }; 460 | 9695851810F3C63900978746 /* PBXTextBookmark */ = { 461 | isa = PBXTextBookmark; 462 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 463 | name = "aboo.m: 91"; 464 | rLen = 0; 465 | rLoc = 1942; 466 | rType = 0; 467 | vrLen = 422; 468 | vrLoc = 2126; 469 | }; 470 | 9695852110F3C65000978746 /* PBXTextBookmark */ = { 471 | isa = PBXTextBookmark; 472 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 473 | name = "aboo.m: 91"; 474 | rLen = 0; 475 | rLoc = 1942; 476 | rType = 0; 477 | vrLen = 422; 478 | vrLoc = 2126; 479 | }; 480 | 9695852410F3C66800978746 /* PBXTextBookmark */ = { 481 | isa = PBXTextBookmark; 482 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 483 | name = "aboo.m: 127"; 484 | rLen = 6; 485 | rLoc = 2821; 486 | rType = 0; 487 | vrLen = 1217; 488 | vrLoc = 2839; 489 | }; 490 | 9695852710F3C7CC00978746 /* PBXTextBookmark */ = { 491 | isa = PBXTextBookmark; 492 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 493 | name = "aboo.m: 141"; 494 | rLen = 0; 495 | rLoc = 3483; 496 | rType = 0; 497 | vrLen = 1201; 498 | vrLoc = 2808; 499 | }; 500 | 9695852A10F3C7EE00978746 /* PBXTextBookmark */ = { 501 | isa = PBXTextBookmark; 502 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 503 | name = "aboo.m: 141"; 504 | rLen = 0; 505 | rLoc = 3483; 506 | rType = 0; 507 | vrLen = 1212; 508 | vrLoc = 2808; 509 | }; 510 | 9695853110F3C84500978746 /* PBXTextBookmark */ = { 511 | isa = PBXTextBookmark; 512 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 513 | name = "aboo.m: 141"; 514 | rLen = 0; 515 | rLoc = 3483; 516 | rType = 0; 517 | vrLen = 1239; 518 | vrLoc = 2808; 519 | }; 520 | 9695853410F3C86400978746 /* PBXTextBookmark */ = { 521 | isa = PBXTextBookmark; 522 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 523 | name = "aboo.m: 141"; 524 | rLen = 0; 525 | rLoc = 3483; 526 | rType = 0; 527 | vrLen = 1250; 528 | vrLoc = 2808; 529 | }; 530 | 9695853710F3C8C500978746 /* PBXTextBookmark */ = { 531 | isa = PBXTextBookmark; 532 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 533 | name = "aboo.m: 141"; 534 | rLen = 0; 535 | rLoc = 3458; 536 | rType = 0; 537 | vrLen = 1181; 538 | vrLoc = 2808; 539 | }; 540 | 9695853E10F3CA1300978746 /* PBXTextBookmark */ = { 541 | isa = PBXTextBookmark; 542 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 543 | name = "aboo.m: 141"; 544 | rLen = 0; 545 | rLoc = 3285; 546 | rType = 0; 547 | vrLen = 1079; 548 | vrLoc = 2808; 549 | }; 550 | 9695854110F3CA7300978746 /* PBXTextBookmark */ = { 551 | isa = PBXTextBookmark; 552 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 553 | name = "aboo.m: 144"; 554 | rLen = 0; 555 | rLoc = 3456; 556 | rType = 0; 557 | vrLen = 1136; 558 | vrLoc = 2808; 559 | }; 560 | 9695854410F3CB7E00978746 /* PBXTextBookmark */ = { 561 | isa = PBXTextBookmark; 562 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 563 | name = "aboo.m: 142"; 564 | rLen = 0; 565 | rLoc = 3346; 566 | rType = 0; 567 | vrLen = 1130; 568 | vrLoc = 2808; 569 | }; 570 | 9695854710F3CB9E00978746 /* PBXTextBookmark */ = { 571 | isa = PBXTextBookmark; 572 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 573 | name = "aboo.m: 143"; 574 | rLen = 0; 575 | rLoc = 3453; 576 | rType = 0; 577 | vrLen = 1136; 578 | vrLoc = 2808; 579 | }; 580 | 9695854A10F3CDD000978746 /* XCBuildMessageTextBookmark */ = { 581 | isa = PBXTextBookmark; 582 | comments = "'bday' undeclared (first use in this function)"; 583 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 584 | fallbackIsa = XCBuildMessageTextBookmark; 585 | rLen = 1; 586 | rLoc = 147; 587 | rType = 1; 588 | }; 589 | 9695854B10F3CDD000978746 /* PBXTextBookmark */ = { 590 | isa = PBXTextBookmark; 591 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 592 | name = "aboo.m: 177"; 593 | rLen = 0; 594 | rLoc = 3679; 595 | rType = 0; 596 | vrLen = 439; 597 | vrLoc = 4422; 598 | }; 599 | 9695855410F3CE9D00978746 /* XCBuildMessageTextBookmark */ = { 600 | isa = PBXTextBookmark; 601 | comments = "'bday' undeclared (first use in this function)"; 602 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 603 | fallbackIsa = XCBuildMessageTextBookmark; 604 | rLen = 1; 605 | rLoc = 147; 606 | rType = 1; 607 | }; 608 | 9695855510F3CE9D00978746 /* PBXTextBookmark */ = { 609 | isa = PBXTextBookmark; 610 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 611 | name = "aboo.m: 150"; 612 | rLen = 0; 613 | rLoc = 3528; 614 | rType = 0; 615 | vrLen = 1705; 616 | vrLoc = 3623; 617 | }; 618 | 9695855810F3CED900978746 /* PBXTextBookmark */ = { 619 | isa = PBXTextBookmark; 620 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 621 | name = "aboo.m: 38"; 622 | rLen = 0; 623 | rLoc = 1119; 624 | rType = 0; 625 | vrLen = 927; 626 | vrLoc = 842; 627 | }; 628 | 9695855B10F3CF0200978746 /* PBXTextBookmark */ = { 629 | isa = PBXTextBookmark; 630 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 631 | name = "aboo.m: 157"; 632 | rLen = 0; 633 | rLoc = 3658; 634 | rType = 0; 635 | vrLen = 1737; 636 | vrLoc = 3563; 637 | }; 638 | 9695855E10F3CF5E00978746 /* PBXTextBookmark */ = { 639 | isa = PBXTextBookmark; 640 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 641 | name = "aboo.m: 354"; 642 | rLen = 0; 643 | rLoc = 8080; 644 | rType = 0; 645 | vrLen = 1531; 646 | vrLoc = 9537; 647 | }; 648 | 9695856110F3D07B00978746 /* PBXTextBookmark */ = { 649 | isa = PBXTextBookmark; 650 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 651 | name = "aboo.m: 34"; 652 | rLen = 0; 653 | rLoc = 1083; 654 | rType = 0; 655 | vrLen = 1092; 656 | vrLoc = 366; 657 | }; 658 | 969D91DB10F23AA80071FD44 /* aboo */ = { 659 | isa = PBXExecutable; 660 | activeArgIndices = ( 661 | ); 662 | argumentStrings = ( 663 | ); 664 | autoAttachOnCrash = 1; 665 | breakpointsEnabled = 0; 666 | configStateDict = { 667 | }; 668 | customDataFormattersEnabled = 1; 669 | dataTipCustomDataFormattersEnabled = 1; 670 | dataTipShowTypeColumn = 1; 671 | dataTipSortType = 0; 672 | debuggerPlugin = GDBDebugging; 673 | disassemblyDisplayState = 0; 674 | dylibVariantSuffix = ""; 675 | enableDebugStr = 1; 676 | environmentEntries = ( 677 | ); 678 | executableSystemSymbolLevel = 0; 679 | executableUserSymbolLevel = 0; 680 | libgmallocEnabled = 0; 681 | name = aboo; 682 | savedGlobals = { 683 | }; 684 | showTypeColumn = 0; 685 | sourceDirectories = ( 686 | ); 687 | }; 688 | 969D91E610F23AB10071FD44 /* Source Control */ = { 689 | isa = PBXSourceControlManager; 690 | fallbackIsa = XCSourceControlManager; 691 | isSCMEnabled = 0; 692 | scmConfiguration = { 693 | repositoryNamesForRoots = { 694 | "" = ""; 695 | }; 696 | }; 697 | }; 698 | 969D91E710F23AB10071FD44 /* Code sense */ = { 699 | isa = PBXCodeSenseManager; 700 | indexTemplatePath = ""; 701 | }; 702 | 969D91EE10F23BFB0071FD44 /* RegexKitLite.h */ = { 703 | uiCtxt = { 704 | sepNavIntBoundsRect = "{{0, 0}, {673, 2912}}"; 705 | sepNavSelRange = "{0, 0}"; 706 | sepNavVisRange = "{0, 1378}"; 707 | }; 708 | }; 709 | 969D92B510F240D40071FD44 /* PBXTextBookmark */ = { 710 | isa = PBXTextBookmark; 711 | fRef = 969D91EE10F23BFB0071FD44 /* RegexKitLite.h */; 712 | name = "RegexKitLite.h: 1"; 713 | rLen = 0; 714 | rLoc = 0; 715 | rType = 0; 716 | vrLen = 1378; 717 | vrLoc = 0; 718 | }; 719 | 969EE52810F26EFA00A8A873 /* PBXTextBookmark */ = { 720 | isa = PBXTextBookmark; 721 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 722 | name = "aboo.m: 2"; 723 | rLen = 0; 724 | rLoc = 69; 725 | rType = 0; 726 | vrLen = 1251; 727 | vrLoc = 0; 728 | }; 729 | 96E1FE7E10F243F20052FC4A /* PBXTextBookmark */ = { 730 | isa = PBXTextBookmark; 731 | fRef = 08FB7796FE84155DC02AAC07 /* aboo.m */; 732 | name = "aboo.m: 19"; 733 | rLen = 0; 734 | rLoc = 205; 735 | rType = 0; 736 | vrLen = 900; 737 | vrLoc = 0; 738 | }; 739 | } 740 | -------------------------------------------------------------------------------- /aboo.xcodeproj/chneeb.mode1v3: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ActivePerspectiveName 6 | Project 7 | AllowedModules 8 | 9 | 10 | BundleLoadPath 11 | 12 | MaxInstances 13 | n 14 | Module 15 | PBXSmartGroupTreeModule 16 | Name 17 | Groups and Files Outline View 18 | 19 | 20 | BundleLoadPath 21 | 22 | MaxInstances 23 | n 24 | Module 25 | PBXNavigatorGroup 26 | Name 27 | Editor 28 | 29 | 30 | BundleLoadPath 31 | 32 | MaxInstances 33 | n 34 | Module 35 | XCTaskListModule 36 | Name 37 | Task List 38 | 39 | 40 | BundleLoadPath 41 | 42 | MaxInstances 43 | n 44 | Module 45 | XCDetailModule 46 | Name 47 | File and Smart Group Detail Viewer 48 | 49 | 50 | BundleLoadPath 51 | 52 | MaxInstances 53 | 1 54 | Module 55 | PBXBuildResultsModule 56 | Name 57 | Detailed Build Results Viewer 58 | 59 | 60 | BundleLoadPath 61 | 62 | MaxInstances 63 | 1 64 | Module 65 | PBXProjectFindModule 66 | Name 67 | Project Batch Find Tool 68 | 69 | 70 | BundleLoadPath 71 | 72 | MaxInstances 73 | n 74 | Module 75 | XCProjectFormatConflictsModule 76 | Name 77 | Project Format Conflicts List 78 | 79 | 80 | BundleLoadPath 81 | 82 | MaxInstances 83 | n 84 | Module 85 | PBXBookmarksModule 86 | Name 87 | Bookmarks Tool 88 | 89 | 90 | BundleLoadPath 91 | 92 | MaxInstances 93 | n 94 | Module 95 | PBXClassBrowserModule 96 | Name 97 | Class Browser 98 | 99 | 100 | BundleLoadPath 101 | 102 | MaxInstances 103 | n 104 | Module 105 | PBXCVSModule 106 | Name 107 | Source Code Control Tool 108 | 109 | 110 | BundleLoadPath 111 | 112 | MaxInstances 113 | n 114 | Module 115 | PBXDebugBreakpointsModule 116 | Name 117 | Debug Breakpoints Tool 118 | 119 | 120 | BundleLoadPath 121 | 122 | MaxInstances 123 | n 124 | Module 125 | XCDockableInspector 126 | Name 127 | Inspector 128 | 129 | 130 | BundleLoadPath 131 | 132 | MaxInstances 133 | n 134 | Module 135 | PBXOpenQuicklyModule 136 | Name 137 | Open Quickly Tool 138 | 139 | 140 | BundleLoadPath 141 | 142 | MaxInstances 143 | 1 144 | Module 145 | PBXDebugSessionModule 146 | Name 147 | Debugger 148 | 149 | 150 | BundleLoadPath 151 | 152 | MaxInstances 153 | 1 154 | Module 155 | PBXDebugCLIModule 156 | Name 157 | Debug Console 158 | 159 | 160 | BundleLoadPath 161 | 162 | MaxInstances 163 | n 164 | Module 165 | XCSnapshotModule 166 | Name 167 | Snapshots Tool 168 | 169 | 170 | BundlePath 171 | /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources 172 | Description 173 | DefaultDescriptionKey 174 | DockingSystemVisible 175 | 176 | Extension 177 | mode1v3 178 | FavBarConfig 179 | 180 | PBXProjectModuleGUID 181 | 969D91E310F23AB10071FD44 182 | XCBarModuleItemNames 183 | 184 | XCBarModuleItems 185 | 186 | 187 | FirstTimeWindowDisplayed 188 | 189 | Identifier 190 | com.apple.perspectives.project.mode1v3 191 | MajorVersion 192 | 33 193 | MinorVersion 194 | 0 195 | Name 196 | Default 197 | Notifications 198 | 199 | OpenEditors 200 | 201 | PerspectiveWidths 202 | 203 | -1 204 | -1 205 | 206 | Perspectives 207 | 208 | 209 | ChosenToolbarItems 210 | 211 | active-combo-popup 212 | action 213 | NSToolbarFlexibleSpaceItem 214 | debugger-enable-breakpoints 215 | build-and-go 216 | com.apple.ide.PBXToolbarStopButton 217 | get-info 218 | NSToolbarFlexibleSpaceItem 219 | com.apple.pbx.toolbar.searchfield 220 | 221 | ControllerClassBaseName 222 | 223 | IconName 224 | WindowOfProjectWithEditor 225 | Identifier 226 | perspective.project 227 | IsVertical 228 | 229 | Layout 230 | 231 | 232 | ContentConfiguration 233 | 234 | PBXBottomSmartGroupGIDs 235 | 236 | 1C37FBAC04509CD000000102 237 | 1C37FAAC04509CD000000102 238 | 1C37FABC05509CD000000102 239 | 1C37FABC05539CD112110102 240 | E2644B35053B69B200211256 241 | 1C37FABC04509CD000100104 242 | 1CC0EA4004350EF90044410B 243 | 1CC0EA4004350EF90041110B 244 | 245 | PBXProjectModuleGUID 246 | 1CE0B1FE06471DED0097A5F4 247 | PBXProjectModuleLabel 248 | Files 249 | PBXProjectStructureProvided 250 | yes 251 | PBXSmartGroupTreeModuleColumnData 252 | 253 | PBXSmartGroupTreeModuleColumnWidthsKey 254 | 255 | 204 256 | 257 | PBXSmartGroupTreeModuleColumnsKey_v4 258 | 259 | MainColumn 260 | 261 | 262 | PBXSmartGroupTreeModuleOutlineStateKey_v7 263 | 264 | PBXSmartGroupTreeModuleOutlineStateExpansionKey 265 | 266 | 08FB7794FE84155DC02AAC07 267 | 08FB7795FE84155DC02AAC07 268 | 1C37FABC05509CD000000102 269 | 270 | PBXSmartGroupTreeModuleOutlineStateSelectionKey 271 | 272 | 273 | 4 274 | 2 275 | 0 276 | 277 | 278 | PBXSmartGroupTreeModuleOutlineStateVisibleRectKey 279 | {{0, 0}, {204, 783}} 280 | 281 | PBXTopSmartGroupGIDs 282 | 283 | XCIncludePerspectivesSwitch 284 | 285 | XCSharingToken 286 | com.apple.Xcode.GFSharingToken 287 | 288 | GeometryConfiguration 289 | 290 | Frame 291 | {{0, 0}, {221, 801}} 292 | GroupTreeTableConfiguration 293 | 294 | MainColumn 295 | 204 296 | 297 | RubberWindowFrame 298 | 293 149 1048 842 0 0 1680 1028 299 | 300 | Module 301 | PBXSmartGroupTreeModule 302 | Proportion 303 | 221pt 304 | 305 | 306 | Dock 307 | 308 | 309 | BecomeActive 310 | 311 | ContentConfiguration 312 | 313 | PBXProjectModuleGUID 314 | 1CE0B20306471E060097A5F4 315 | PBXProjectModuleLabel 316 | aboo.m 317 | PBXSplitModuleInNavigatorKey 318 | 319 | Split0 320 | 321 | PBXProjectModuleGUID 322 | 1CE0B20406471E060097A5F4 323 | PBXProjectModuleLabel 324 | aboo.m 325 | _historyCapacity 326 | 0 327 | bookmark 328 | 9695856110F3D07B00978746 329 | history 330 | 331 | 969D92B510F240D40071FD44 332 | 9695855410F3CE9D00978746 333 | 334 | 335 | SplitCount 336 | 1 337 | 338 | StatusBarVisibility 339 | 340 | 341 | GeometryConfiguration 342 | 343 | Frame 344 | {{0, 0}, {822, 598}} 345 | RubberWindowFrame 346 | 293 149 1048 842 0 0 1680 1028 347 | 348 | Module 349 | PBXNavigatorGroup 350 | Proportion 351 | 598pt 352 | 353 | 354 | ContentConfiguration 355 | 356 | PBXProjectModuleGUID 357 | 1CE0B20506471E060097A5F4 358 | PBXProjectModuleLabel 359 | Detail 360 | 361 | GeometryConfiguration 362 | 363 | Frame 364 | {{0, 603}, {822, 198}} 365 | RubberWindowFrame 366 | 293 149 1048 842 0 0 1680 1028 367 | 368 | Module 369 | XCDetailModule 370 | Proportion 371 | 198pt 372 | 373 | 374 | Proportion 375 | 822pt 376 | 377 | 378 | Name 379 | Project 380 | ServiceClasses 381 | 382 | XCModuleDock 383 | PBXSmartGroupTreeModule 384 | XCModuleDock 385 | PBXNavigatorGroup 386 | XCDetailModule 387 | 388 | TableOfContents 389 | 390 | 969584C210F397EE00978746 391 | 1CE0B1FE06471DED0097A5F4 392 | 969584C310F397EE00978746 393 | 1CE0B20306471E060097A5F4 394 | 1CE0B20506471E060097A5F4 395 | 396 | ToolbarConfigUserDefaultsMinorVersion 397 | 2 398 | ToolbarConfiguration 399 | xcode.toolbar.config.defaultV3 400 | 401 | 402 | ControllerClassBaseName 403 | 404 | IconName 405 | WindowOfProject 406 | Identifier 407 | perspective.morph 408 | IsVertical 409 | 0 410 | Layout 411 | 412 | 413 | BecomeActive 414 | 1 415 | ContentConfiguration 416 | 417 | PBXBottomSmartGroupGIDs 418 | 419 | 1C37FBAC04509CD000000102 420 | 1C37FAAC04509CD000000102 421 | 1C08E77C0454961000C914BD 422 | 1C37FABC05509CD000000102 423 | 1C37FABC05539CD112110102 424 | E2644B35053B69B200211256 425 | 1C37FABC04509CD000100104 426 | 1CC0EA4004350EF90044410B 427 | 1CC0EA4004350EF90041110B 428 | 429 | PBXProjectModuleGUID 430 | 11E0B1FE06471DED0097A5F4 431 | PBXProjectModuleLabel 432 | Files 433 | PBXProjectStructureProvided 434 | yes 435 | PBXSmartGroupTreeModuleColumnData 436 | 437 | PBXSmartGroupTreeModuleColumnWidthsKey 438 | 439 | 186 440 | 441 | PBXSmartGroupTreeModuleColumnsKey_v4 442 | 443 | MainColumn 444 | 445 | 446 | PBXSmartGroupTreeModuleOutlineStateKey_v7 447 | 448 | PBXSmartGroupTreeModuleOutlineStateExpansionKey 449 | 450 | 29B97314FDCFA39411CA2CEA 451 | 1C37FABC05509CD000000102 452 | 453 | PBXSmartGroupTreeModuleOutlineStateSelectionKey 454 | 455 | 456 | 0 457 | 458 | 459 | PBXSmartGroupTreeModuleOutlineStateVisibleRectKey 460 | {{0, 0}, {186, 337}} 461 | 462 | PBXTopSmartGroupGIDs 463 | 464 | XCIncludePerspectivesSwitch 465 | 1 466 | XCSharingToken 467 | com.apple.Xcode.GFSharingToken 468 | 469 | GeometryConfiguration 470 | 471 | Frame 472 | {{0, 0}, {203, 355}} 473 | GroupTreeTableConfiguration 474 | 475 | MainColumn 476 | 186 477 | 478 | RubberWindowFrame 479 | 373 269 690 397 0 0 1440 878 480 | 481 | Module 482 | PBXSmartGroupTreeModule 483 | Proportion 484 | 100% 485 | 486 | 487 | Name 488 | Morph 489 | PreferredWidth 490 | 300 491 | ServiceClasses 492 | 493 | XCModuleDock 494 | PBXSmartGroupTreeModule 495 | 496 | TableOfContents 497 | 498 | 11E0B1FE06471DED0097A5F4 499 | 500 | ToolbarConfiguration 501 | xcode.toolbar.config.default.shortV3 502 | 503 | 504 | PerspectivesBarVisible 505 | 506 | ShelfIsVisible 507 | 508 | SourceDescription 509 | file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' 510 | StatusbarIsVisible 511 | 512 | TimeStamp 513 | 0.0 514 | ToolbarConfigUserDefaultsMinorVersion 515 | 2 516 | ToolbarDisplayMode 517 | 1 518 | ToolbarIsVisible 519 | 520 | ToolbarSizeMode 521 | 1 522 | Type 523 | Perspectives 524 | UpdateMessage 525 | The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? 526 | WindowJustification 527 | 5 528 | WindowOrderList 529 | 530 | 969D91E410F23AB10071FD44 531 | /Users/chneeb/Source/aboo/aboo.xcodeproj 532 | 533 | WindowString 534 | 293 149 1048 842 0 0 1680 1028 535 | WindowToolsV3 536 | 537 | 538 | FirstTimeWindowDisplayed 539 | 540 | Identifier 541 | windowTool.build 542 | IsVertical 543 | 544 | Layout 545 | 546 | 547 | Dock 548 | 549 | 550 | ContentConfiguration 551 | 552 | PBXProjectModuleGUID 553 | 1CD0528F0623707200166675 554 | PBXProjectModuleLabel 555 | aboo.m 556 | StatusBarVisibility 557 | 558 | 559 | GeometryConfiguration 560 | 561 | Frame 562 | {{0, 0}, {500, 218}} 563 | RubberWindowFrame 564 | 467 388 500 500 0 0 1680 1028 565 | 566 | Module 567 | PBXNavigatorGroup 568 | Proportion 569 | 218pt 570 | 571 | 572 | BecomeActive 573 | 574 | ContentConfiguration 575 | 576 | PBXProjectModuleGUID 577 | XCMainBuildResultsModuleGUID 578 | PBXProjectModuleLabel 579 | Build Results 580 | XCBuildResultsTrigger_Collapse 581 | 1021 582 | XCBuildResultsTrigger_Open 583 | 1011 584 | 585 | GeometryConfiguration 586 | 587 | Frame 588 | {{0, 223}, {500, 236}} 589 | RubberWindowFrame 590 | 467 388 500 500 0 0 1680 1028 591 | 592 | Module 593 | PBXBuildResultsModule 594 | Proportion 595 | 236pt 596 | 597 | 598 | Proportion 599 | 459pt 600 | 601 | 602 | Name 603 | Build Results 604 | ServiceClasses 605 | 606 | PBXBuildResultsModule 607 | 608 | StatusbarIsVisible 609 | 610 | TableOfContents 611 | 612 | 969D91E410F23AB10071FD44 613 | 969584B910F397B100978746 614 | 1CD0528F0623707200166675 615 | XCMainBuildResultsModuleGUID 616 | 617 | ToolbarConfiguration 618 | xcode.toolbar.config.buildV3 619 | WindowContentMinSize 620 | 486 300 621 | WindowString 622 | 467 388 500 500 0 0 1680 1028 623 | WindowToolGUID 624 | 969D91E410F23AB10071FD44 625 | WindowToolIsVisible 626 | 627 | 628 | 629 | FirstTimeWindowDisplayed 630 | 631 | Identifier 632 | windowTool.debugger 633 | IsVertical 634 | 635 | Layout 636 | 637 | 638 | Dock 639 | 640 | 641 | ContentConfiguration 642 | 643 | Debugger 644 | 645 | HorizontalSplitView 646 | 647 | _collapsingFrameDimension 648 | 0.0 649 | _indexOfCollapsedView 650 | 0 651 | _percentageOfCollapsedView 652 | 0.0 653 | isCollapsed 654 | yes 655 | sizes 656 | 657 | {{0, 0}, {316, 194}} 658 | {{316, 0}, {378, 194}} 659 | 660 | 661 | VerticalSplitView 662 | 663 | _collapsingFrameDimension 664 | 0.0 665 | _indexOfCollapsedView 666 | 0 667 | _percentageOfCollapsedView 668 | 0.0 669 | isCollapsed 670 | yes 671 | sizes 672 | 673 | {{0, 0}, {694, 194}} 674 | {{0, 194}, {694, 187}} 675 | 676 | 677 | 678 | LauncherConfigVersion 679 | 8 680 | PBXProjectModuleGUID 681 | 1C162984064C10D400B95A72 682 | PBXProjectModuleLabel 683 | Debug - GLUTExamples (Underwater) 684 | 685 | GeometryConfiguration 686 | 687 | DebugConsoleVisible 688 | None 689 | DebugConsoleWindowFrame 690 | {{200, 200}, {500, 300}} 691 | DebugSTDIOWindowFrame 692 | {{200, 200}, {500, 300}} 693 | Frame 694 | {{0, 0}, {694, 381}} 695 | PBXDebugSessionStackFrameViewKey 696 | 697 | DebugVariablesTableConfiguration 698 | 699 | Name 700 | 120 701 | Value 702 | 85 703 | Summary 704 | 148 705 | 706 | Frame 707 | {{316, 0}, {378, 194}} 708 | RubberWindowFrame 709 | 641 506 694 422 0 0 1680 1028 710 | 711 | RubberWindowFrame 712 | 641 506 694 422 0 0 1680 1028 713 | 714 | Module 715 | PBXDebugSessionModule 716 | Proportion 717 | 381pt 718 | 719 | 720 | Proportion 721 | 381pt 722 | 723 | 724 | Name 725 | Debugger 726 | ServiceClasses 727 | 728 | PBXDebugSessionModule 729 | 730 | StatusbarIsVisible 731 | 732 | TableOfContents 733 | 734 | 1CD10A99069EF8BA00B06720 735 | 96E1FE8210F243F20052FC4A 736 | 1C162984064C10D400B95A72 737 | 96E1FE8310F243F20052FC4A 738 | 96E1FE8410F243F20052FC4A 739 | 96E1FE8510F243F20052FC4A 740 | 96E1FE8610F243F20052FC4A 741 | 96E1FE8710F243F20052FC4A 742 | 743 | ToolbarConfiguration 744 | xcode.toolbar.config.debugV3 745 | WindowString 746 | 641 506 694 422 0 0 1680 1028 747 | WindowToolGUID 748 | 1CD10A99069EF8BA00B06720 749 | WindowToolIsVisible 750 | 751 | 752 | 753 | Identifier 754 | windowTool.find 755 | Layout 756 | 757 | 758 | Dock 759 | 760 | 761 | Dock 762 | 763 | 764 | ContentConfiguration 765 | 766 | PBXProjectModuleGUID 767 | 1CDD528C0622207200134675 768 | PBXProjectModuleLabel 769 | <No Editor> 770 | PBXSplitModuleInNavigatorKey 771 | 772 | Split0 773 | 774 | PBXProjectModuleGUID 775 | 1CD0528D0623707200166675 776 | 777 | SplitCount 778 | 1 779 | 780 | StatusBarVisibility 781 | 1 782 | 783 | GeometryConfiguration 784 | 785 | Frame 786 | {{0, 0}, {781, 167}} 787 | RubberWindowFrame 788 | 62 385 781 470 0 0 1440 878 789 | 790 | Module 791 | PBXNavigatorGroup 792 | Proportion 793 | 781pt 794 | 795 | 796 | Proportion 797 | 50% 798 | 799 | 800 | BecomeActive 801 | 1 802 | ContentConfiguration 803 | 804 | PBXProjectModuleGUID 805 | 1CD0528E0623707200166675 806 | PBXProjectModuleLabel 807 | Project Find 808 | 809 | GeometryConfiguration 810 | 811 | Frame 812 | {{8, 0}, {773, 254}} 813 | RubberWindowFrame 814 | 62 385 781 470 0 0 1440 878 815 | 816 | Module 817 | PBXProjectFindModule 818 | Proportion 819 | 50% 820 | 821 | 822 | Proportion 823 | 428pt 824 | 825 | 826 | Name 827 | Project Find 828 | ServiceClasses 829 | 830 | PBXProjectFindModule 831 | 832 | StatusbarIsVisible 833 | 1 834 | TableOfContents 835 | 836 | 1C530D57069F1CE1000CFCEE 837 | 1C530D58069F1CE1000CFCEE 838 | 1C530D59069F1CE1000CFCEE 839 | 1CDD528C0622207200134675 840 | 1C530D5A069F1CE1000CFCEE 841 | 1CE0B1FE06471DED0097A5F4 842 | 1CD0528E0623707200166675 843 | 844 | WindowString 845 | 62 385 781 470 0 0 1440 878 846 | WindowToolGUID 847 | 1C530D57069F1CE1000CFCEE 848 | WindowToolIsVisible 849 | 0 850 | 851 | 852 | Identifier 853 | MENUSEPARATOR 854 | 855 | 856 | FirstTimeWindowDisplayed 857 | 858 | Identifier 859 | windowTool.debuggerConsole 860 | IsVertical 861 | 862 | Layout 863 | 864 | 865 | Dock 866 | 867 | 868 | ContentConfiguration 869 | 870 | PBXProjectModuleGUID 871 | 1C78EAAC065D492600B07095 872 | PBXProjectModuleLabel 873 | Debugger Console 874 | 875 | GeometryConfiguration 876 | 877 | Frame 878 | {{0, 0}, {650, 209}} 879 | RubberWindowFrame 880 | 641 678 650 250 0 0 1680 1028 881 | 882 | Module 883 | PBXDebugCLIModule 884 | Proportion 885 | 209pt 886 | 887 | 888 | Proportion 889 | 209pt 890 | 891 | 892 | Name 893 | Debugger Console 894 | ServiceClasses 895 | 896 | PBXDebugCLIModule 897 | 898 | StatusbarIsVisible 899 | 900 | TableOfContents 901 | 902 | 1C78EAAD065D492600B07095 903 | 96E1FE8810F243F20052FC4A 904 | 1C78EAAC065D492600B07095 905 | 906 | ToolbarConfiguration 907 | xcode.toolbar.config.consoleV3 908 | WindowString 909 | 641 678 650 250 0 0 1680 1028 910 | WindowToolGUID 911 | 1C78EAAD065D492600B07095 912 | WindowToolIsVisible 913 | 914 | 915 | 916 | Identifier 917 | windowTool.snapshots 918 | Layout 919 | 920 | 921 | Dock 922 | 923 | 924 | Module 925 | XCSnapshotModule 926 | Proportion 927 | 100% 928 | 929 | 930 | Proportion 931 | 100% 932 | 933 | 934 | Name 935 | Snapshots 936 | ServiceClasses 937 | 938 | XCSnapshotModule 939 | 940 | StatusbarIsVisible 941 | Yes 942 | ToolbarConfiguration 943 | xcode.toolbar.config.snapshots 944 | WindowString 945 | 315 824 300 550 0 0 1440 878 946 | WindowToolIsVisible 947 | Yes 948 | 949 | 950 | Identifier 951 | windowTool.scm 952 | Layout 953 | 954 | 955 | Dock 956 | 957 | 958 | ContentConfiguration 959 | 960 | PBXProjectModuleGUID 961 | 1C78EAB2065D492600B07095 962 | PBXProjectModuleLabel 963 | <No Editor> 964 | PBXSplitModuleInNavigatorKey 965 | 966 | Split0 967 | 968 | PBXProjectModuleGUID 969 | 1C78EAB3065D492600B07095 970 | 971 | SplitCount 972 | 1 973 | 974 | StatusBarVisibility 975 | 1 976 | 977 | GeometryConfiguration 978 | 979 | Frame 980 | {{0, 0}, {452, 0}} 981 | RubberWindowFrame 982 | 743 379 452 308 0 0 1280 1002 983 | 984 | Module 985 | PBXNavigatorGroup 986 | Proportion 987 | 0pt 988 | 989 | 990 | BecomeActive 991 | 1 992 | ContentConfiguration 993 | 994 | PBXProjectModuleGUID 995 | 1CD052920623707200166675 996 | PBXProjectModuleLabel 997 | SCM 998 | 999 | GeometryConfiguration 1000 | 1001 | ConsoleFrame 1002 | {{0, 259}, {452, 0}} 1003 | Frame 1004 | {{0, 7}, {452, 259}} 1005 | RubberWindowFrame 1006 | 743 379 452 308 0 0 1280 1002 1007 | TableConfiguration 1008 | 1009 | Status 1010 | 30 1011 | FileName 1012 | 199 1013 | Path 1014 | 197.0950012207031 1015 | 1016 | TableFrame 1017 | {{0, 0}, {452, 250}} 1018 | 1019 | Module 1020 | PBXCVSModule 1021 | Proportion 1022 | 262pt 1023 | 1024 | 1025 | Proportion 1026 | 266pt 1027 | 1028 | 1029 | Name 1030 | SCM 1031 | ServiceClasses 1032 | 1033 | PBXCVSModule 1034 | 1035 | StatusbarIsVisible 1036 | 1 1037 | TableOfContents 1038 | 1039 | 1C78EAB4065D492600B07095 1040 | 1C78EAB5065D492600B07095 1041 | 1C78EAB2065D492600B07095 1042 | 1CD052920623707200166675 1043 | 1044 | ToolbarConfiguration 1045 | xcode.toolbar.config.scm 1046 | WindowString 1047 | 743 379 452 308 0 0 1280 1002 1048 | 1049 | 1050 | Identifier 1051 | windowTool.breakpoints 1052 | IsVertical 1053 | 0 1054 | Layout 1055 | 1056 | 1057 | Dock 1058 | 1059 | 1060 | BecomeActive 1061 | 1 1062 | ContentConfiguration 1063 | 1064 | PBXBottomSmartGroupGIDs 1065 | 1066 | 1C77FABC04509CD000000102 1067 | 1068 | PBXProjectModuleGUID 1069 | 1CE0B1FE06471DED0097A5F4 1070 | PBXProjectModuleLabel 1071 | Files 1072 | PBXProjectStructureProvided 1073 | no 1074 | PBXSmartGroupTreeModuleColumnData 1075 | 1076 | PBXSmartGroupTreeModuleColumnWidthsKey 1077 | 1078 | 168 1079 | 1080 | PBXSmartGroupTreeModuleColumnsKey_v4 1081 | 1082 | MainColumn 1083 | 1084 | 1085 | PBXSmartGroupTreeModuleOutlineStateKey_v7 1086 | 1087 | PBXSmartGroupTreeModuleOutlineStateExpansionKey 1088 | 1089 | 1C77FABC04509CD000000102 1090 | 1091 | PBXSmartGroupTreeModuleOutlineStateSelectionKey 1092 | 1093 | 1094 | 0 1095 | 1096 | 1097 | PBXSmartGroupTreeModuleOutlineStateVisibleRectKey 1098 | {{0, 0}, {168, 350}} 1099 | 1100 | PBXTopSmartGroupGIDs 1101 | 1102 | XCIncludePerspectivesSwitch 1103 | 0 1104 | 1105 | GeometryConfiguration 1106 | 1107 | Frame 1108 | {{0, 0}, {185, 368}} 1109 | GroupTreeTableConfiguration 1110 | 1111 | MainColumn 1112 | 168 1113 | 1114 | RubberWindowFrame 1115 | 315 424 744 409 0 0 1440 878 1116 | 1117 | Module 1118 | PBXSmartGroupTreeModule 1119 | Proportion 1120 | 185pt 1121 | 1122 | 1123 | ContentConfiguration 1124 | 1125 | PBXProjectModuleGUID 1126 | 1CA1AED706398EBD00589147 1127 | PBXProjectModuleLabel 1128 | Detail 1129 | 1130 | GeometryConfiguration 1131 | 1132 | Frame 1133 | {{190, 0}, {554, 368}} 1134 | RubberWindowFrame 1135 | 315 424 744 409 0 0 1440 878 1136 | 1137 | Module 1138 | XCDetailModule 1139 | Proportion 1140 | 554pt 1141 | 1142 | 1143 | Proportion 1144 | 368pt 1145 | 1146 | 1147 | MajorVersion 1148 | 3 1149 | MinorVersion 1150 | 0 1151 | Name 1152 | Breakpoints 1153 | ServiceClasses 1154 | 1155 | PBXSmartGroupTreeModule 1156 | XCDetailModule 1157 | 1158 | StatusbarIsVisible 1159 | 1 1160 | TableOfContents 1161 | 1162 | 1CDDB66807F98D9800BB5817 1163 | 1CDDB66907F98D9800BB5817 1164 | 1CE0B1FE06471DED0097A5F4 1165 | 1CA1AED706398EBD00589147 1166 | 1167 | ToolbarConfiguration 1168 | xcode.toolbar.config.breakpointsV3 1169 | WindowString 1170 | 315 424 744 409 0 0 1440 878 1171 | WindowToolGUID 1172 | 1CDDB66807F98D9800BB5817 1173 | WindowToolIsVisible 1174 | 1 1175 | 1176 | 1177 | Identifier 1178 | windowTool.debugAnimator 1179 | Layout 1180 | 1181 | 1182 | Dock 1183 | 1184 | 1185 | Module 1186 | PBXNavigatorGroup 1187 | Proportion 1188 | 100% 1189 | 1190 | 1191 | Proportion 1192 | 100% 1193 | 1194 | 1195 | Name 1196 | Debug Visualizer 1197 | ServiceClasses 1198 | 1199 | PBXNavigatorGroup 1200 | 1201 | StatusbarIsVisible 1202 | 1 1203 | ToolbarConfiguration 1204 | xcode.toolbar.config.debugAnimatorV3 1205 | WindowString 1206 | 100 100 700 500 0 0 1280 1002 1207 | 1208 | 1209 | Identifier 1210 | windowTool.bookmarks 1211 | Layout 1212 | 1213 | 1214 | Dock 1215 | 1216 | 1217 | Module 1218 | PBXBookmarksModule 1219 | Proportion 1220 | 100% 1221 | 1222 | 1223 | Proportion 1224 | 100% 1225 | 1226 | 1227 | Name 1228 | Bookmarks 1229 | ServiceClasses 1230 | 1231 | PBXBookmarksModule 1232 | 1233 | StatusbarIsVisible 1234 | 0 1235 | WindowString 1236 | 538 42 401 187 0 0 1280 1002 1237 | 1238 | 1239 | Identifier 1240 | windowTool.projectFormatConflicts 1241 | Layout 1242 | 1243 | 1244 | Dock 1245 | 1246 | 1247 | Module 1248 | XCProjectFormatConflictsModule 1249 | Proportion 1250 | 100% 1251 | 1252 | 1253 | Proportion 1254 | 100% 1255 | 1256 | 1257 | Name 1258 | Project Format Conflicts 1259 | ServiceClasses 1260 | 1261 | XCProjectFormatConflictsModule 1262 | 1263 | StatusbarIsVisible 1264 | 0 1265 | WindowContentMinSize 1266 | 450 300 1267 | WindowString 1268 | 50 850 472 307 0 0 1440 877 1269 | 1270 | 1271 | Identifier 1272 | windowTool.classBrowser 1273 | Layout 1274 | 1275 | 1276 | Dock 1277 | 1278 | 1279 | BecomeActive 1280 | 1 1281 | ContentConfiguration 1282 | 1283 | OptionsSetName 1284 | Hierarchy, all classes 1285 | PBXProjectModuleGUID 1286 | 1CA6456E063B45B4001379D8 1287 | PBXProjectModuleLabel 1288 | Class Browser - NSObject 1289 | 1290 | GeometryConfiguration 1291 | 1292 | ClassesFrame 1293 | {{0, 0}, {374, 96}} 1294 | ClassesTreeTableConfiguration 1295 | 1296 | PBXClassNameColumnIdentifier 1297 | 208 1298 | PBXClassBookColumnIdentifier 1299 | 22 1300 | 1301 | Frame 1302 | {{0, 0}, {630, 331}} 1303 | MembersFrame 1304 | {{0, 105}, {374, 395}} 1305 | MembersTreeTableConfiguration 1306 | 1307 | PBXMemberTypeIconColumnIdentifier 1308 | 22 1309 | PBXMemberNameColumnIdentifier 1310 | 216 1311 | PBXMemberTypeColumnIdentifier 1312 | 97 1313 | PBXMemberBookColumnIdentifier 1314 | 22 1315 | 1316 | PBXModuleWindowStatusBarHidden2 1317 | 1 1318 | RubberWindowFrame 1319 | 385 179 630 352 0 0 1440 878 1320 | 1321 | Module 1322 | PBXClassBrowserModule 1323 | Proportion 1324 | 332pt 1325 | 1326 | 1327 | Proportion 1328 | 332pt 1329 | 1330 | 1331 | Name 1332 | Class Browser 1333 | ServiceClasses 1334 | 1335 | PBXClassBrowserModule 1336 | 1337 | StatusbarIsVisible 1338 | 0 1339 | TableOfContents 1340 | 1341 | 1C0AD2AF069F1E9B00FABCE6 1342 | 1C0AD2B0069F1E9B00FABCE6 1343 | 1CA6456E063B45B4001379D8 1344 | 1345 | ToolbarConfiguration 1346 | xcode.toolbar.config.classbrowser 1347 | WindowString 1348 | 385 179 630 352 0 0 1440 878 1349 | WindowToolGUID 1350 | 1C0AD2AF069F1E9B00FABCE6 1351 | WindowToolIsVisible 1352 | 0 1353 | 1354 | 1355 | Identifier 1356 | windowTool.refactoring 1357 | IncludeInToolsMenu 1358 | 0 1359 | Layout 1360 | 1361 | 1362 | Dock 1363 | 1364 | 1365 | BecomeActive 1366 | 1 1367 | GeometryConfiguration 1368 | 1369 | Frame 1370 | {0, 0}, {500, 335} 1371 | RubberWindowFrame 1372 | {0, 0}, {500, 335} 1373 | 1374 | Module 1375 | XCRefactoringModule 1376 | Proportion 1377 | 100% 1378 | 1379 | 1380 | Proportion 1381 | 100% 1382 | 1383 | 1384 | Name 1385 | Refactoring 1386 | ServiceClasses 1387 | 1388 | XCRefactoringModule 1389 | 1390 | WindowString 1391 | 200 200 500 356 0 0 1920 1200 1392 | 1393 | 1394 | 1395 | 1396 | -------------------------------------------------------------------------------- /RegexKitLite.m: -------------------------------------------------------------------------------- 1 | // 2 | // RegexKitLite.m 3 | // http://regexkit.sourceforge.net/ 4 | // Licensed under the terms of the BSD License, as specified below. 5 | // 6 | 7 | /* 8 | Copyright (c) 2008-2009, John Engelhart 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | 22 | * Neither the name of the Zang Industries nor the names of its 23 | contributors may be used to endorse or promote products derived from 24 | this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 32 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | */ 38 | 39 | #include 40 | #include 41 | #include 42 | #import 43 | #import 44 | #import 45 | #import 46 | #import 47 | #import 48 | #ifdef __OBJC_GC__ 49 | #import 50 | #define RKL_STRONG_REF __strong 51 | #else // __OBJC_GC__ 52 | #define RKL_STRONG_REF 53 | #endif // __OBJC_GC__ 54 | 55 | #if (defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0)) || (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)) 56 | #include 57 | #else 58 | #include 59 | #endif 60 | 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | 70 | #import "RegexKitLite.h" 71 | 72 | // If the gcc flag -mmacosx-version-min is used with, for example, '=10.2', give a warning that the libicucore.dylib is only available on >= 10.3. 73 | // If you are reading this comment because of this warning, this is to let you know that linking to /usr/lib/libicucore.dylib will cause your executable to fail on < 10.3. 74 | // You will need to build your own version of the ICU library and link to that in order for RegexKitLite to work successfully on < 10.3. This is not simple. 75 | 76 | #if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 77 | #warning The ICU dynamic shared library, /usr/lib/libicucore.dylib, is only available on Mac OS X 10.3 and later. 78 | #warning You will need to supply a version of the ICU library to use RegexKitLite on Mac OS X 10.2 and earlier. 79 | #endif 80 | 81 | //////////// 82 | #pragma mark Compile time tuneables 83 | 84 | #ifndef RKL_CACHE_SIZE 85 | #define RKL_CACHE_SIZE (23UL) 86 | #endif 87 | 88 | #ifndef RKL_FIXED_LENGTH 89 | #define RKL_FIXED_LENGTH (2048UL) 90 | #endif 91 | 92 | #ifndef RKL_STACK_LIMIT 93 | #define RKL_STACK_LIMIT (128UL * 1024UL) 94 | #endif 95 | 96 | #ifdef RKL_APPEND_TO_ICU_FUNCTIONS 97 | #define RKL_ICU_FUNCTION_APPEND(x) _RKL_CONCAT(x, RKL_APPEND_TO_ICU_FUNCTIONS) 98 | #else // RKL_APPEND_TO_ICU_FUNCTIONS 99 | #define RKL_ICU_FUNCTION_APPEND(x) x 100 | #endif // RKL_APPEND_TO_ICU_FUNCTIONS 101 | 102 | #if defined(RKL_DTRACE) && (RKL_DTRACE != 0) 103 | #define _RKL_DTRACE_ENABLED 104 | #endif // defined(RKL_DTRACE) && (RKL_DTRACE != 0) 105 | 106 | // These are internal, non-public tuneables. 107 | #define RKL_SCRATCH_BUFFERS (4UL) 108 | #define RKL_CACHE_LINE_SIZE (64UL) 109 | #define RKL_DTRACE_REGEXUTF8_SIZE (64UL) 110 | 111 | ////////////// 112 | #pragma mark - 113 | #pragma mark GCC / Compiler macros 114 | 115 | #if defined (__GNUC__) && (__GNUC__ >= 4) 116 | #define RKL_ATTRIBUTES(attr, ...) __attribute__((attr, ##__VA_ARGS__)) 117 | #define RKL_EXPECTED(cond, expect) __builtin_expect((long)(cond), (expect)) 118 | #define RKL_PREFETCH(ptr) __builtin_prefetch(ptr) 119 | #define RKL_PREFETCH_UNICHAR(ptr, off) { const char *p = ((const char *)(ptr)) + ((off) * sizeof(UniChar)) + RKL_CACHE_LINE_SIZE; RKL_PREFETCH(p); RKL_PREFETCH(p + RKL_CACHE_LINE_SIZE); } 120 | #define RKL_HAVE_CLEANUP 121 | #define RKL_CLEANUP(func) RKL_ATTRIBUTES(cleanup(func)) 122 | #else // defined (__GNUC__) && (__GNUC__ >= 4) 123 | #define RKL_ATTRIBUTES(attr, ...) 124 | #define RKL_EXPECTED(cond, expect) (cond) 125 | #define RKL_PREFETCH(ptr) 126 | #define RKL_PREFETCH_UNICHAR(ptr, off) 127 | #define RKL_CLEANUP(func) 128 | #endif // defined (__GNUC__) && (__GNUC__ >= 4) 129 | 130 | #define RKL_STATIC_INLINE static __inline__ RKL_ATTRIBUTES(always_inline) 131 | #define RKL_UNUSED_ARG RKL_ATTRIBUTES(unused) 132 | #define RKL_NONNULL_ARGS(arg, ...) RKL_ATTRIBUTES(nonnull(arg, ##__VA_ARGS__)) 133 | #define RKL_NONNULL_ARGS_WARN_UNUSED(arg, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(arg, ##__VA_ARGS__)) 134 | 135 | #if defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) 136 | #define RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__), alloc_size(as)) 137 | #else // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) 138 | #define RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__)) 139 | #endif // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) 140 | 141 | 142 | //////////// 143 | #pragma mark - 144 | #pragma mark Assertion macros 145 | 146 | // These macros are nearly identical to their NSCParameterAssert siblings. 147 | // This is required because nearly everything is done while cacheSpinLock is locked. 148 | // We need to safely unlock before throwing any of these exceptions. 149 | // @try {} @finally {} significantly slows things down so it's not used. 150 | 151 | #define RKLCAssertDictionary(d, ...) rkl_makeAssertDictionary(__PRETTY_FUNCTION__, __FILE__, __LINE__, (d), ##__VA_ARGS__) 152 | #define RKLCDelayedHardAssert(c, e, g) do { id *_e=(e); int _c=(c); if(RKL_EXPECTED(_e == NULL, 0L) || RKL_EXPECTED(*_e != NULL, 0L)) { goto g; } if(RKL_EXPECTED(!_c, 0L)) { *_e = RKLCAssertDictionary(@"Invalid parameter not satisfying: %s", #c); goto g; } } while(0) 153 | 154 | #ifdef NS_BLOCK_ASSERTIONS 155 | #define RKLCDelayedAssert(c, e, g) 156 | #define RKL_UNUSED_ASSERTION_ARG RKL_ATTRIBUTES(unused) 157 | #else // NS_BLOCK_ASSERTIONS 158 | #define RKLCDelayedAssert(c, e, g) RKLCDelayedHardAssert(c, e, g) 159 | #define RKL_UNUSED_ASSERTION_ARG 160 | #endif // NS_BLOCK_ASSERTIONS 161 | 162 | #define RKL_EXCEPTION(e, f, ...) [NSException exceptionWithName:(e) reason:rkl_stringFromClassAndMethod((self), (_cmd), (f), ##__VA_ARGS__) userInfo:NULL] 163 | #define RKL_RAISE_EXCEPTION(e, f, ...) [RKL_EXCEPTION(e, f, ##__VA_ARGS__) raise] 164 | 165 | //////////// 166 | #pragma mark - 167 | #pragma mark Utility functions and macros 168 | 169 | RKL_STATIC_INLINE BOOL NSRangeInsideRange(NSRange cin, NSRange win) RKL_ATTRIBUTES(warn_unused_result); 170 | RKL_STATIC_INLINE BOOL NSRangeInsideRange(NSRange cin, NSRange win) { return((((cin.location - win.location) <= win.length) && ((NSMaxRange(cin) - win.location) <= win.length)) ? YES : NO); } 171 | 172 | #define NSMakeRange(loc, len) ((NSRange){.location=(NSUInteger)(loc), .length=(NSUInteger)(len)}) 173 | #define CFMakeRange(loc, len) ((CFRange){.location= (CFIndex)(loc), .length= (CFIndex)(len)}) 174 | #define NSNotFoundRange ((NSRange){.location=(NSUInteger)NSNotFound, .length= 0UL}) 175 | #define NSMaxiumRange ((NSRange){.location= 0UL, .length= NSUIntegerMax}) 176 | 177 | //////////// 178 | #pragma mark - 179 | #pragma mark Exported NSString symbols for exception names, error domains, error keys, etc 180 | 181 | NSString * const RKLICURegexException = @"RKLICURegexException"; 182 | 183 | NSString * const RKLICURegexErrorDomain = @"RKLICURegexErrorDomain"; 184 | 185 | NSString * const RKLICURegexErrorCodeErrorKey = @"RKLICURegexErrorCode"; 186 | NSString * const RKLICURegexErrorNameErrorKey = @"RKLICURegexErrorName"; 187 | NSString * const RKLICURegexLineErrorKey = @"RKLICURegexLine"; 188 | NSString * const RKLICURegexOffsetErrorKey = @"RKLICURegexOffset"; 189 | NSString * const RKLICURegexPreContextErrorKey = @"RKLICURegexPreContext"; 190 | NSString * const RKLICURegexPostContextErrorKey = @"RKLICURegexPostContext"; 191 | NSString * const RKLICURegexRegexErrorKey = @"RKLICURegexRegex"; 192 | NSString * const RKLICURegexRegexOptionsErrorKey = @"RKLICURegexRegexOptions"; 193 | 194 | //////////// 195 | #pragma mark - 196 | #pragma mark Type / struct definitions 197 | 198 | // In general, the ICU bits and pieces here must exactly match the definition in the ICU sources. 199 | 200 | #define U_STRING_NOT_TERMINATED_WARNING -124 201 | #define U_ZERO_ERROR 0 202 | #define U_INDEX_OUTOFBOUNDS_ERROR 8 203 | #define U_BUFFER_OVERFLOW_ERROR 15 204 | #define U_PARSE_CONTEXT_LEN 16 205 | 206 | typedef struct uregex uregex; // Opaque ICU regex type. 207 | 208 | typedef struct UParseError { // This must be exactly the same as the 'real' ICU declaration. 209 | int32_t line; 210 | int32_t offset; 211 | UniChar preContext[U_PARSE_CONTEXT_LEN]; 212 | UniChar postContext[U_PARSE_CONTEXT_LEN]; 213 | } UParseError; 214 | 215 | // For use with GCC's cleanup() __attribute__. 216 | #define RKLLockedCacheSpinLock ((NSUInteger)(1UL<<0)) 217 | #define RKLUnlockedCacheSpinLock ((NSUInteger)(1UL<<1)) 218 | 219 | enum { 220 | RKLSplitOp = 1, 221 | RKLReplaceOp = 2, 222 | RKLRangeOp = 3, 223 | RKLArrayOfStringsOp = 4, 224 | RKLArrayOfCapturesOp = 5, 225 | RKLCapturesArrayOp = 6, 226 | RKLMaskOp = 0xf, 227 | RKLReplaceMutable = 1 << 4, 228 | RKLSubcapturesArray = 1 << 5, 229 | }; 230 | typedef NSUInteger RKLRegexOp; 231 | 232 | typedef struct { 233 | NSRange *ranges, findInRange; 234 | NSInteger capacity, found, findUpTo, capture; 235 | size_t size, stackUsed; 236 | void **rangesScratchBuffer; 237 | RKL_STRONG_REF void **stringsScratchBuffer; 238 | RKL_STRONG_REF void **arraysScratchBuffer; 239 | } RKLFindAll; 240 | 241 | typedef struct { 242 | CFStringRef string; 243 | CFHashCode hash; 244 | CFIndex length; 245 | RKL_STRONG_REF UniChar *uniChar; 246 | } RKLBuffer; 247 | 248 | typedef struct { 249 | CFStringRef regexString; 250 | RKLRegexOptions options; 251 | uregex *icu_regex; 252 | NSInteger captureCount; 253 | 254 | CFStringRef setToString; 255 | CFHashCode setToHash; 256 | CFIndex setToLength; 257 | NSUInteger setToIsImmutable:1; 258 | NSUInteger setToNeedsConversion:1; 259 | const UniChar *setToUniChar; 260 | NSRange setToRange, lastFindRange, lastMatchRange; 261 | #ifndef __LP64__ 262 | NSUInteger pad[1]; // For 32 bits, this makes the struct 64 bytes exactly, which is good for cache line alignment. 263 | #endif // __LP64__ 264 | } RKLCacheSlot; 265 | 266 | //////////// 267 | #pragma mark - 268 | #pragma mark Translation unit scope global variables 269 | 270 | static UniChar fixedUniChar[(RKL_FIXED_LENGTH)]; // This is the fixed sized UTF-16 conversion buffer. 271 | static RKLCacheSlot rkl_cacheSlots[(RKL_CACHE_SIZE)], *lastCacheSlot; 272 | static OSSpinLock cacheSpinLock = OS_SPINLOCK_INIT; 273 | static RKLBuffer dynamicBuffer, fixedBuffer = {NULL, 0UL, 0L, &fixedUniChar[0]}; 274 | static const UniChar emptyUniCharString[1]; // For safety, icu_regexes are 'set' to this when the string they were searched is cleared. 275 | static RKL_STRONG_REF void *scratchBuffer[(RKL_SCRATCH_BUFFERS)]; // Used to hold temporary allocations that are allocated via reallocf(). 276 | 277 | //////////// 278 | #pragma mark - 279 | #pragma mark CFArray call backs 280 | 281 | // These are used when running under manual memory management for the array that rkl_splitArray creates. 282 | // The split strings are created, but not autoreleased. The (immutable) array is created using these callbacks, which skips the CFRetain() call, effectively transferring ownership to the CFArray object. 283 | // For each split string this saves the overhead of an autorelease, then an array retain, then an NSAutoreleasePool release. This is good for a ~30% speed increase. 284 | 285 | static void RKLCFArrayRelease (CFAllocatorRef allocator RKL_UNUSED_ARG, const void *ptr) { CFRelease((CFTypeRef)ptr); } 286 | static const CFArrayCallBacks rkl_transferOwnershipArrayCallBacks = { (CFIndex)0L, NULL, RKLCFArrayRelease, CFCopyDescription, CFEqual }; 287 | 288 | #ifdef __OBJC_GC__ 289 | //////////// 290 | #pragma mark - 291 | #pragma mark Low-level Garbage Collection aware memory/resource allocation utilities 292 | // If compiled with Garbage Collection, we need to be able to do a few things slightly differently. 293 | // The basic premiss is that under GC we use a trampoline function pointer which is set to a _start function to catch the first invocation. 294 | // The _start function checks if GC is running and then overwrites the function pointer with the appropriate routine. Think of it as 'lazy linking'. 295 | 296 | enum { RKLScannedOption = NSScannedOption }; 297 | 298 | // rkl_collectingEnabled uses objc_getClass() to get the NSGarbageCollector class, which doesn't exist on earlier systems. 299 | // This allows for graceful failure should we find ourselves running on an earlier version of the OS without NSGarbageCollector. 300 | static BOOL rkl_collectingEnabled_first (void); 301 | static BOOL rkl_collectingEnabled_yes (void) { return(YES); } 302 | static BOOL rkl_collectingEnabled_no (void) { return(NO); } 303 | static BOOL(*rkl_collectingEnabled) (void) = rkl_collectingEnabled_first; 304 | static BOOL rkl_collectingEnabled_first (void) { 305 | BOOL gcEnabled = ([objc_getClass("NSGarbageCollector") defaultCollector] != NULL) ? YES : NO; 306 | if(gcEnabled == YES) { 307 | // This section of code is required due to what I consider to be a fundamental design flaw in Cocoas GC system. 308 | // Earlier versions of "Garbage Collection Programming Guide" stated that (paraphrased) "all globals are automatically roots". 309 | // Current versions of the guide now include the following warning: 310 | // "You may pass addresses of strong globals or statics into routines expecting pointers to object pointers (such as id* or NSError**) 311 | // only if they have first been assigned to directly, rather than through a pointer dereference." 312 | // This is a surprisingly non-trivial condition to actually meet in practice and is a recipe for impossible to debug race condition bugs. 313 | // We just happen to be very, very, very lucky in the fact that we can initilize our root set before the first use. 314 | int x; 315 | for(x = 0; x < (int)(RKL_SCRATCH_BUFFERS); x++) { scratchBuffer[x] = NSAllocateCollectable(16UL, 0UL); scratchBuffer[x] = NULL; } 316 | dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)NSAllocateCollectable(16UL, 0UL); dynamicBuffer.uniChar = NULL; 317 | } 318 | return((rkl_collectingEnabled = (gcEnabled == YES) ? rkl_collectingEnabled_yes : rkl_collectingEnabled_no)()); 319 | } 320 | 321 | // rkl_realloc() 322 | static void *rkl_realloc_first (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags); 323 | static void *rkl_realloc_std (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags RKL_UNUSED_ARG) { return((*ptr = reallocf(*ptr, size))); } 324 | static void *rkl_realloc_gc (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) { return((*ptr = NSReallocateCollectable(*ptr, (NSUInteger)size, flags))); } 325 | static void *(*rkl_realloc) (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(2,1) = rkl_realloc_first; 326 | static void *rkl_realloc_first (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) { if(rkl_collectingEnabled()==YES) { rkl_realloc = rkl_realloc_gc; } else { rkl_realloc = rkl_realloc_std; } return(rkl_realloc(ptr, size, flags)); } 327 | 328 | // rkl_free() 329 | static void * rkl_free_first (RKL_STRONG_REF void **ptr); 330 | static void * rkl_free_std (RKL_STRONG_REF void **ptr) { if(*ptr != NULL) { free(*ptr); *ptr = NULL; } return(NULL); } 331 | static void * rkl_free_gc (RKL_STRONG_REF void **ptr) { if(*ptr != NULL) { *ptr = NULL; } return(NULL); } 332 | static void *(*rkl_free) (RKL_STRONG_REF void **ptr) RKL_NONNULL_ARGS(1) = rkl_free_first; 333 | static void *rkl_free_first (RKL_STRONG_REF void **ptr) { if(rkl_collectingEnabled()==YES) { rkl_free = rkl_free_gc; } else { rkl_free = rkl_free_std; } return(rkl_free(ptr)); } 334 | 335 | // rkl_CFAutorelease() 336 | static id rkl_CFAutorelease_first (CFTypeRef obj); 337 | static id rkl_CFAutorelease_std (CFTypeRef obj) { return([(id)obj autorelease]); } 338 | static id rkl_CFAutorelease_gc (CFTypeRef obj) { return(NSMakeCollectable(obj)); } 339 | static id(*rkl_CFAutorelease) (CFTypeRef obj) = rkl_CFAutorelease_first; 340 | static id rkl_CFAutorelease_first (CFTypeRef obj) { return((rkl_CFAutorelease = (rkl_collectingEnabled()==YES) ? rkl_CFAutorelease_gc : rkl_CFAutorelease_std)(obj)); } 341 | 342 | // rkl_CreateStringWithSubstring() 343 | static id rkl_CreateStringWithSubstring_first (id string, NSRange range); 344 | static id rkl_CreateStringWithSubstring_std (id string, NSRange range) { return((id)CFStringCreateWithSubstring(NULL, (CFStringRef)string, CFMakeRange((CFIndex)range.location, (CFIndex)range.length))); } 345 | static id rkl_CreateStringWithSubstring_gc (id string, NSRange range) { return([string substringWithRange:range]); } 346 | static id(*rkl_CreateStringWithSubstring) (id string, NSRange range) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateStringWithSubstring_first; 347 | static id rkl_CreateStringWithSubstring_first (id string, NSRange range) { return((rkl_CreateStringWithSubstring = (rkl_collectingEnabled()==YES) ? rkl_CreateStringWithSubstring_gc : rkl_CreateStringWithSubstring_std)(string, range)); } 348 | 349 | // rkl_ReleaseObject() 350 | static id rkl_ReleaseObject_first (id obj); 351 | static id rkl_ReleaseObject_std (id obj) { CFRelease((CFTypeRef)obj); return(NULL); } 352 | static id rkl_ReleaseObject_gc (id obj RKL_UNUSED_ARG) { return(NULL); } 353 | static id (*rkl_ReleaseObject) (id obj) RKL_NONNULL_ARGS(1) = rkl_ReleaseObject_first; 354 | static id rkl_ReleaseObject_first (id obj) { return((rkl_ReleaseObject = (rkl_collectingEnabled()==YES) ? rkl_ReleaseObject_gc : rkl_ReleaseObject_std)(obj)); } 355 | 356 | // rkl_CreateArrayWithObjects() 357 | static id rkl_CreateArrayWithObjects_first (void **objects, NSUInteger count); 358 | static id rkl_CreateArrayWithObjects_std (void **objects, NSUInteger count) { return((id)CFArrayCreate(NULL, (const void **)objects, (CFIndex)count, &rkl_transferOwnershipArrayCallBacks)); } 359 | static id rkl_CreateArrayWithObjects_gc (void **objects, NSUInteger count) { return([NSArray arrayWithObjects:(const id *)objects count:count]); } 360 | static id(*rkl_CreateArrayWithObjects) (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateArrayWithObjects_first; 361 | static id rkl_CreateArrayWithObjects_first (void **objects, NSUInteger count) { return((rkl_CreateArrayWithObjects = (rkl_collectingEnabled()==YES) ? rkl_CreateArrayWithObjects_gc : rkl_CreateArrayWithObjects_std)(objects, count)); } 362 | 363 | // rkl_CreateAutoreleasedArray() 364 | static id rkl_CreateAutoreleasedArray_first (void **objects, NSUInteger count); 365 | static id rkl_CreateAutoreleasedArray_std (void **objects, NSUInteger count) { return((id)rkl_CFAutorelease(rkl_CreateArrayWithObjects(objects, count))); } 366 | static id rkl_CreateAutoreleasedArray_gc (void **objects, NSUInteger count) { return( rkl_CreateArrayWithObjects(objects, count) ); } 367 | static id(*rkl_CreateAutoreleasedArray) (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateAutoreleasedArray_first; 368 | static id rkl_CreateAutoreleasedArray_first (void **objects, NSUInteger count) { return((rkl_CreateAutoreleasedArray = (rkl_collectingEnabled()==YES) ? rkl_CreateAutoreleasedArray_gc : rkl_CreateAutoreleasedArray_std)(objects, count)); } 369 | 370 | #else // __OBJC_GC__ not defined 371 | //////////// 372 | #pragma mark - 373 | #pragma mark Low-level explicit memory/resource allocation utilities 374 | 375 | enum { RKLScannedOption = 0 }; 376 | 377 | #define rkl_collectingEnabled() (NO) 378 | 379 | RKL_STATIC_INLINE void *rkl_realloc (void **ptr, size_t size, NSUInteger flags) RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(2,1); 380 | RKL_STATIC_INLINE void *rkl_free (void **ptr) RKL_NONNULL_ARGS(1); 381 | RKL_STATIC_INLINE id rkl_CFAutorelease (CFTypeRef obj); 382 | RKL_STATIC_INLINE id rkl_CreateAutoreleasedArray (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1); 383 | RKL_STATIC_INLINE id rkl_CreateArrayWithObjects (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1); 384 | RKL_STATIC_INLINE id rkl_CreateStringWithSubstring (id string, NSRange range) RKL_NONNULL_ARGS_WARN_UNUSED(1); 385 | RKL_STATIC_INLINE id rkl_ReleaseObject (id obj) RKL_NONNULL_ARGS(1); 386 | 387 | RKL_STATIC_INLINE void *rkl_realloc (void **ptr, size_t size, NSUInteger flags RKL_UNUSED_ARG) { return((*ptr = reallocf(*ptr, size))); } 388 | RKL_STATIC_INLINE void *rkl_free (void **ptr) { if(*ptr != NULL) { free(*ptr); *ptr = NULL; } return(NULL); } 389 | RKL_STATIC_INLINE id rkl_CFAutorelease (CFTypeRef obj) { return([(id)obj autorelease]); } 390 | RKL_STATIC_INLINE id rkl_CreateArrayWithObjects (void **objects, NSUInteger count) { return((id)CFArrayCreate(NULL, (const void **)objects, (CFIndex)count, &rkl_transferOwnershipArrayCallBacks)); } 391 | RKL_STATIC_INLINE id rkl_CreateAutoreleasedArray (void **objects, NSUInteger count) { return(rkl_CFAutorelease(rkl_CreateArrayWithObjects(objects, count))); } 392 | RKL_STATIC_INLINE id rkl_CreateStringWithSubstring (id string, NSRange range) { return((id)CFStringCreateWithSubstring(NULL, (CFStringRef)string, CFMakeRange((CFIndex)range.location, (CFIndex)range.length))); } 393 | RKL_STATIC_INLINE id rkl_ReleaseObject (id obj) { CFRelease((CFTypeRef)obj); return(NULL); } 394 | 395 | #endif // __OBJC_GC__ 396 | 397 | //////////// 398 | #pragma mark - 399 | #pragma mark ICU function prototypes 400 | 401 | // ICU functions. See http://www.icu-project.org/apiref/icu4c/uregex_8h.html Tweaked slightly from the originals, but functionally identical. 402 | const char *RKL_ICU_FUNCTION_APPEND(u_errorName) (int32_t status) RKL_ATTRIBUTES(pure); 403 | int32_t RKL_ICU_FUNCTION_APPEND(u_strlen) (const UniChar *s) RKL_ATTRIBUTES(nonnull(1), pure); 404 | int32_t RKL_ICU_FUNCTION_APPEND(uregex_appendReplacement) (uregex *regexp, const UniChar *replacementText, int32_t replacementLength, UniChar **destBuf, int32_t *destCapacity, int32_t *status) RKL_NONNULL_ARGS(1,2,4,5,6); 405 | int32_t RKL_ICU_FUNCTION_APPEND(uregex_appendTail) (uregex *regexp, UniChar **destBuf, int32_t *destCapacity, int32_t *status) RKL_NONNULL_ARGS(1,2,3,4); 406 | void RKL_ICU_FUNCTION_APPEND(uregex_close) (uregex *regexp) RKL_NONNULL_ARGS(1); 407 | int32_t RKL_ICU_FUNCTION_APPEND(uregex_end) (uregex *regexp, int32_t groupNum, int32_t *status) RKL_NONNULL_ARGS(1,3); 408 | BOOL RKL_ICU_FUNCTION_APPEND(uregex_find) (uregex *regexp, int32_t location, int32_t *status) RKL_NONNULL_ARGS(1,3); 409 | BOOL RKL_ICU_FUNCTION_APPEND(uregex_findNext) (uregex *regexp, int32_t *status) RKL_NONNULL_ARGS(1,2); 410 | int32_t RKL_ICU_FUNCTION_APPEND(uregex_groupCount) (uregex *regexp, int32_t *status) RKL_NONNULL_ARGS(1,2); 411 | uregex *RKL_ICU_FUNCTION_APPEND(uregex_open) (const UniChar *pattern, int32_t patternLength, RKLRegexOptions flags, UParseError *parseError, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,4,5); 412 | void RKL_ICU_FUNCTION_APPEND(uregex_reset) (uregex *regexp, int32_t newIndex, int32_t *status) RKL_NONNULL_ARGS(1,3); 413 | void RKL_ICU_FUNCTION_APPEND(uregex_setText) (uregex *regexp, const UniChar *text, int32_t textLength, int32_t *status) RKL_NONNULL_ARGS(1,2,4); 414 | int32_t RKL_ICU_FUNCTION_APPEND(uregex_start) (uregex *regexp, int32_t groupNum, int32_t *status) RKL_NONNULL_ARGS(1,3); 415 | 416 | //////////// 417 | #pragma mark - 418 | #pragma mark RegexKitLite internal, private function prototypes 419 | 420 | static RKLCacheSlot *rkl_getCachedRegex (NSString *regexString, RKLRegexOptions options, NSError **error, id *exception) RKL_NONNULL_ARGS_WARN_UNUSED(1,4); 421 | static NSUInteger rkl_setCacheSlotToString (RKLCacheSlot *cacheSlot, const NSRange *range, int32_t *status, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,3,4); 422 | static RKLCacheSlot *rkl_getCachedRegexSetToString (NSString *regexString, RKLRegexOptions options, NSString *matchString, NSUInteger *matchLengthPtr, NSRange *matchRange, NSError **error, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4,5,7,8); 423 | static id rkl_performRegexOp (id self, SEL _cmd, RKLRegexOp regexOp, NSString *regexString, RKLRegexOptions options, NSInteger capture, id matchString, NSRange *matchRange, NSString *replacementString, NSError **error, void *result) RKL_NONNULL_ARGS(1,2); 424 | static void rkl_handleDelayedAssert (id self, SEL _cmd, id exception) RKL_NONNULL_ARGS(1,2,3); 425 | 426 | static NSUInteger rkl_search (RKLCacheSlot *cacheSlot, NSRange *searchRange, NSUInteger updateSearchRange, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,5); 427 | 428 | static BOOL rkl_findRanges (RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4,5); 429 | static NSUInteger rkl_growFindRanges (RKLCacheSlot *cacheSlot, NSUInteger lastLocation, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4); 430 | static NSArray *rkl_makeArray (RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4); 431 | 432 | static NSString *rkl_replaceString (RKLCacheSlot *cacheSlot, id searchString, NSUInteger searchU16Length, NSString *replacementString, NSUInteger replacementU16Length, NSUInteger *replacedCount, NSUInteger replaceMutable, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,8,9); 433 | static int32_t rkl_replaceAll (RKLCacheSlot *cacheSlot, const UniChar *replacementUniChar, int32_t replacementU16Length, UniChar *replacedUniChar, int32_t replacedU16Capacity, NSUInteger *replacedCount, int32_t *needU16Capacity, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,6,7,8,9); 434 | 435 | static NSUInteger rkl_isRegexValid (id self, SEL _cmd, NSString *regex, RKLRegexOptions options, NSInteger *captureCountPtr, NSError **error) RKL_NONNULL_ARGS(1,2); 436 | 437 | static void rkl_clearStringCache (void); 438 | static void rkl_clearBuffer (RKLBuffer *buffer, NSUInteger freeDynamicBuffer) RKL_NONNULL_ARGS(1); 439 | static void rkl_clearCacheSlotRegex (RKLCacheSlot *cacheSlot) RKL_NONNULL_ARGS(1); 440 | static void rkl_clearCacheSlotSetTo (RKLCacheSlot *cacheSlot) RKL_NONNULL_ARGS(1); 441 | 442 | static NSDictionary *rkl_userInfoDictionary (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status, ...) RKL_ATTRIBUTES(sentinel, nonnull(1), warn_unused_result); 443 | static NSError *rkl_NSErrorForRegex (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) RKL_NONNULL_ARGS_WARN_UNUSED(1); 444 | static NSException *rkl_NSExceptionForRegex (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) RKL_NONNULL_ARGS_WARN_UNUSED(1); 445 | static NSDictionary *rkl_makeAssertDictionary (const char *function, const char *file, int line, NSString *format, ...) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4); 446 | static NSString *rkl_stringFromClassAndMethod (id object, SEL selector, NSString *format, ...) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,3); 447 | 448 | RKL_STATIC_INLINE int32_t rkl_getRangeForCapture(RKLCacheSlot *cs, int32_t *s, int32_t c, NSRange *r) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4); 449 | RKL_STATIC_INLINE int32_t rkl_getRangeForCapture(RKLCacheSlot *cs, int32_t *s, int32_t c, NSRange *r) { uregex *re = cs->icu_regex; int32_t start = RKL_ICU_FUNCTION_APPEND(uregex_start)(re, c, s); if(RKL_EXPECTED((*s > U_ZERO_ERROR), 0L) || (start == -1)) { *r = NSNotFoundRange; } else { r->location = (NSUInteger)start; r->length = (NSUInteger)RKL_ICU_FUNCTION_APPEND(uregex_end)(re, c, s) - r->location; r->location += cs->setToRange.location; } return(*s); } 450 | 451 | RKL_STATIC_INLINE RKLFindAll rkl_makeFindAll(NSRange *r, NSRange fir, NSInteger c, size_t s, size_t su, void **rsb, RKL_STRONG_REF void **ssb, RKL_STRONG_REF void **asb, NSInteger f, NSInteger cap, NSInteger fut) RKL_ATTRIBUTES(warn_unused_result); 452 | RKL_STATIC_INLINE RKLFindAll rkl_makeFindAll(NSRange *r, NSRange fir, NSInteger c, size_t s, size_t su, void **rsb, RKL_STRONG_REF void **ssb, RKL_STRONG_REF void **asb, NSInteger f, NSInteger cap, NSInteger fut) { return(((RKLFindAll){ .ranges=r, .findInRange=fir, .capacity=c, .found=f, .findUpTo=fut, .capture=cap, .size=s, .stackUsed=su, .rangesScratchBuffer=rsb, .stringsScratchBuffer=ssb, .arraysScratchBuffer=asb})); } 453 | 454 | //////////// 455 | #pragma mark - 456 | #pragma mark RKL_FAST_MUTABLE_CHECK implementation 457 | 458 | #ifdef RKL_FAST_MUTABLE_CHECK 459 | // We use a trampoline function pointer to check at run time if the function __CFStringIsMutable is available. 460 | // If it is, the trampoline function pointer is replaced with the address of that function. 461 | // Otherwise, we assume the worst case that every string is mutable. 462 | // This hopefully helps to protect us since we're using an undocumented, non-public API call. 463 | // We will keep on working if it ever does go away, just with a bit less performance due to the overhead of mutable checks. 464 | 465 | static BOOL rkl_CFStringIsMutable_first (CFStringRef str); 466 | static BOOL rkl_CFStringIsMutable_yes (CFStringRef str RKL_UNUSED_ARG) { return(YES); } 467 | static BOOL(*rkl_CFStringIsMutable) (CFStringRef str) = rkl_CFStringIsMutable_first; 468 | static BOOL rkl_CFStringIsMutable_first (CFStringRef str) { if((rkl_CFStringIsMutable = (BOOL(*)(CFStringRef))dlsym(RTLD_DEFAULT, "__CFStringIsMutable")) == NULL) { rkl_CFStringIsMutable = rkl_CFStringIsMutable_yes; } return(rkl_CFStringIsMutable(str)); } 469 | #else // RKL_FAST_MUTABLE_CHECK is not defined. Assume that all strings are potentially mutable. 470 | #define rkl_CFStringIsMutable(s) (YES) 471 | #endif // RKL_FAST_MUTABLE_CHECK 472 | 473 | 474 | //////////// 475 | #pragma mark - 476 | #pragma mark iPhone / iPod touch low memory notification handler 477 | 478 | #if defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) && (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS == 1) 479 | 480 | // The next few lines are specifically for the iPhone to catch low memory conditions. 481 | // The basic idea is that rkl_RegisterForLowMemoryNotifications() is set to be run once by the linker at load time via __attribute((constructor)). 482 | // rkl_RegisterForLowMemoryNotifications() tries to find the iPhone low memory notification symbol. If it can find it, 483 | // it registers with the default NSNotificationCenter to call the RKLLowMemoryWarningObserver class method +lowMemoryWarning:. 484 | // rkl_RegisterForLowMemoryNotifications() uses an atomic compare and swap to guarantee that it initalizes exactly once. 485 | // +lowMemoryWarning tries to acquire the cache lock. If it gets the lock, it clears the cache. If it can't, it calls performSelector: 486 | // with a delay of half a second to try again. This will hopefully prevent any deadlocks, such as a RegexKitLite request for 487 | // memory triggering a notifcation while the lock is held. 488 | 489 | static void rkl_RegisterForLowMemoryNotifications(void) RKL_ATTRIBUTES(used); 490 | 491 | @interface RKLLowMemoryWarningObserver : NSObject +(void)lowMemoryWarning:(id)notification; @end 492 | @implementation RKLLowMemoryWarningObserver 493 | +(void)lowMemoryWarning:(id)notification { 494 | if(OSSpinLockTry(&cacheSpinLock)) { rkl_clearStringCache(); OSSpinLockUnlock(&cacheSpinLock); } 495 | else { [[RKLLowMemoryWarningObserver class] performSelector:@selector(lowMemoryWarning:) withObject:notification afterDelay:(NSTimeInterval)0.1]; } 496 | } 497 | @end 498 | 499 | static volatile int rkl_HaveRegisteredForLowMemoryNotifications = 0; 500 | 501 | __attribute__((constructor)) static void rkl_RegisterForLowMemoryNotifications(void) { 502 | _Bool didSwap = false; 503 | void **memoryWarningNotification = NULL; 504 | 505 | while((rkl_HaveRegisteredForLowMemoryNotifications == 0) && ((didSwap = OSAtomicCompareAndSwapIntBarrier(0, 1, &rkl_HaveRegisteredForLowMemoryNotifications)) == false)) { /* Allows for spurious CAS failures. */ } 506 | if(didSwap == true) { 507 | if((memoryWarningNotification = (void **)dlsym(RTLD_DEFAULT, "UIApplicationDidReceiveMemoryWarningNotification")) != NULL) { 508 | [[NSNotificationCenter defaultCenter] addObserver:[RKLLowMemoryWarningObserver class] selector:@selector(lowMemoryWarning:) name:(NSString *)*memoryWarningNotification object:NULL]; 509 | } 510 | } 511 | } 512 | 513 | #endif // defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) && (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS == 1) 514 | 515 | #ifdef _RKL_DTRACE_ENABLED 516 | 517 | // compiledRegexCache(unsigned long eventID, const char *regexUTF8, int options, int captures, int hitMiss, int icuStatusCode, const char *icuErrorMessage, double *hitRate); 518 | // utf16ConversionCache(unsigned long eventID, unsigned int lookupResultFlags, double *hitRate, const void *string, unsigned long NSRange.location, unsigned long NSRange.length, long length); 519 | 520 | /* 521 | provider RegexKitLite { 522 | probe compiledRegexCache(unsigned long, const char *, unsigned int, int, int, int, const char *, double *); 523 | probe utf16ConversionCache(unsigned long, unsigned int, double *, const void *, unsigned long, unsigned long, long); 524 | }; 525 | 526 | #pragma D attributes Unstable/Unstable/Common provider RegexKitLite provider 527 | #pragma D attributes Private/Private/Common provider RegexKitLite module 528 | #pragma D attributes Private/Private/Common provider RegexKitLite function 529 | #pragma D attributes Unstable/Unstable/Common provider RegexKitLite name 530 | #pragma D attributes Unstable/Unstable/Common provider RegexKitLite args 531 | */ 532 | 533 | #define REGEXKITLITE_STABILITY "___dtrace_stability$RegexKitLite$v1$4_4_5_1_1_5_1_1_5_4_4_5_4_4_5" 534 | #define REGEXKITLITE_TYPEDEFS "___dtrace_typedefs$RegexKitLite$v1" 535 | #define REGEXKITLITE_COMPILEDREGEXCACHE(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { __asm__ volatile(".reference " REGEXKITLITE_TYPEDEFS); __dtrace_probe$RegexKitLite$compiledRegexCache$v1$756e7369676e6564206c6f6e67$63686172202a$756e7369676e656420696e74$696e74$696e74$696e74$63686172202a$646f75626c65202a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); __asm__ volatile(".reference " REGEXKITLITE_STABILITY); } 536 | #define REGEXKITLITE_COMPILEDREGEXCACHE_ENABLED() __dtrace_isenabled$RegexKitLite$compiledRegexCache$v1() 537 | #define REGEXKITLITE_CONVERTEDSTRINGU16CACHE(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { __asm__ volatile(".reference " REGEXKITLITE_TYPEDEFS); __dtrace_probe$RegexKitLite$utf16ConversionCache$v1$756e7369676e6564206c6f6e67$756e7369676e656420696e74$646f75626c65202a$766f6964202a$756e7369676e6564206c6f6e67$756e7369676e6564206c6f6e67$6c6f6e67(arg0, arg1, arg2, arg3, arg4, arg5, arg6); __asm__ volatile(".reference " REGEXKITLITE_STABILITY); } 538 | #define REGEXKITLITE_CONVERTEDSTRINGU16CACHE_ENABLED() __dtrace_isenabled$RegexKitLite$utf16ConversionCache$v1() 539 | 540 | extern void __dtrace_probe$RegexKitLite$compiledRegexCache$v1$756e7369676e6564206c6f6e67$63686172202a$756e7369676e656420696e74$696e74$696e74$696e74$63686172202a$646f75626c65202a(unsigned long, const char *, unsigned int, int, int, int, const char *, double *); 541 | extern int __dtrace_isenabled$RegexKitLite$compiledRegexCache$v1(void); 542 | extern void __dtrace_probe$RegexKitLite$utf16ConversionCache$v1$756e7369676e6564206c6f6e67$756e7369676e656420696e74$646f75626c65202a$766f6964202a$756e7369676e6564206c6f6e67$756e7369676e6564206c6f6e67$6c6f6e67(unsigned long, unsigned int, double *, const void *, unsigned long, unsigned long, long); 543 | extern int __dtrace_isenabled$RegexKitLite$utf16ConversionCache$v1(void); 544 | 545 | //////////////////////////// 546 | 547 | enum { 548 | RKLCacheHitLookupFlag = 1 << 0, 549 | RKLConversionRequiredLookupFlag = 1 << 1, 550 | RKLSetTextLookupFlag = 1 << 2, 551 | RKLDynamicBufferLookupFlag = 1 << 3, 552 | RKLErrorLookupFlag = 1 << 4, 553 | }; 554 | 555 | #define rkl_dtrace_addLookupFlag(a,b) do { a |= (unsigned int)(b); } while(0) 556 | 557 | static char rkl_dtrace_regexUTF8[(RKL_CACHE_SIZE) + 1][(RKL_DTRACE_REGEXUTF8_SIZE)]; 558 | static NSUInteger rkl_dtrace_eventID, rkl_dtrace_compiledCacheLookups, rkl_dtrace_compiledCacheHits, rkl_dtrace_conversionBufferLookups, rkl_dtrace_conversionBufferHits; 559 | 560 | #define rkl_dtrace_incrementEventID() do { rkl_dtrace_eventID++; } while(0) 561 | #define rkl_dtrace_compiledRegexCache(a0, a1, a2, a3, a4, a5) do { int _a3 = (a3); rkl_dtrace_compiledCacheLookups++; if(_a3 == 1) { rkl_dtrace_compiledCacheHits++; } if(RKL_EXPECTED(REGEXKITLITE_COMPILEDREGEXCACHE_ENABLED(), 0L)) { double hitRate = 0.0; if(rkl_dtrace_compiledCacheLookups > 0UL) { hitRate = ((double)rkl_dtrace_compiledCacheHits / (double)rkl_dtrace_compiledCacheLookups) * 100.0; } REGEXKITLITE_COMPILEDREGEXCACHE(rkl_dtrace_eventID, a0, a1, a2, _a3, a4, a5, &hitRate); } } while(0) 562 | #define rkl_dtrace_utf16ConversionCache(a0, a1, a2, a3, a4) do { unsigned int _a0 = (a0); if((_a0 & RKLConversionRequiredLookupFlag) != 0U) { rkl_dtrace_conversionBufferLookups++; if((_a0 & RKLCacheHitLookupFlag) != 0U) { rkl_dtrace_conversionBufferHits++; } } if(RKL_EXPECTED(REGEXKITLITE_CONVERTEDSTRINGU16CACHE_ENABLED(), 0L)) { double hitRate = 0.0; if(rkl_dtrace_conversionBufferLookups > 0UL) { hitRate = ((double)rkl_dtrace_conversionBufferHits / (double)rkl_dtrace_conversionBufferLookups) * 100.0; } REGEXKITLITE_CONVERTEDSTRINGU16CACHE(rkl_dtrace_eventID, _a0, &hitRate, a1, a2, a3, a4); } } while(0) 563 | 564 | 565 | // \342\200\246 == UTF8 for HORIZONTAL ELLIPSIS, aka triple dots '...' 566 | #define RKL_UTF8_ELLIPSE "\342\200\246" 567 | 568 | // rkl_dtrace_getRegexUTF8 will copy the str argument to utf8Buffer using UTF8 as the string encoding. 569 | // If the utf8 encoding would take up more bytes than the utf8Buffers length, then the unicode character 'HORIZONTAL ELLIPSIS' ('...') is appened to indicate truncation occured. 570 | static void rkl_dtrace_getRegexUTF8(CFStringRef str, char *utf8Buffer) RKL_NONNULL_ARGS(2); 571 | static void rkl_dtrace_getRegexUTF8(CFStringRef str, char *utf8Buffer) { 572 | if((str == NULL) || (utf8Buffer == NULL)) { return; } 573 | CFIndex maxLength = ((CFIndex)(RKL_DTRACE_REGEXUTF8_SIZE) - 2L), maxBytes = (maxLength - (CFIndex)sizeof(RKL_UTF8_ELLIPSE) - 1L), stringU16Length = CFStringGetLength(str), usedBytes = 0L; 574 | CFStringGetBytes(str, CFMakeRange(0L, ((stringU16Length < maxLength) ? stringU16Length : maxLength)), kCFStringEncodingUTF8, (UInt8)'?', (Boolean)0, (UInt8 *)utf8Buffer, maxBytes, &usedBytes); 575 | if(usedBytes == maxBytes) { strncpy(utf8Buffer + usedBytes, RKL_UTF8_ELLIPSE, ((size_t)(RKL_DTRACE_REGEXUTF8_SIZE) - (size_t)usedBytes) - 2UL); } else { utf8Buffer[usedBytes] = (char)0; } 576 | } 577 | 578 | #else // _RKL_DTRACE_ENABLED 579 | 580 | #define rkl_dtrace_incrementEventID() 581 | #define rkl_dtrace_compiledRegexCache(a0, a1, a2, a3, a4, a5) 582 | #define rkl_dtrace_utf16ConversionCache(a0, a1, a2, a3, a4) 583 | #define rkl_dtrace_getRegexUTF8(str, buf) 584 | #define rkl_dtrace_addLookupFlag(a,b) 585 | 586 | #endif // _RKL_DTRACE_ENABLED 587 | 588 | //////////// 589 | #pragma mark - 590 | #pragma mark RegexKitLite low-level internal functions 591 | 592 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 593 | // IMPORTANT! Should only be called with cacheSpinLock already locked! 594 | // ---------- 595 | 596 | static RKLCacheSlot *rkl_getCachedRegex(NSString *regexString, RKLRegexOptions options, NSError **error, id *exception) { 597 | RKLCacheSlot *cacheSlot = NULL; 598 | CFHashCode regexHash = 0UL; 599 | int32_t status = 0; 600 | 601 | RKLCDelayedAssert((cacheSpinLock != (OSSpinLock)0) && (regexString != NULL), exception, exitNow); 602 | 603 | // Fast path the common case where this regex is exactly the same one used last time. 604 | // The pointer equality test is valid under these circumstances since the cacheSlot->regexString is an immutable copy. 605 | // If the regexString argument is mutable, this test will fail, and we'll use the the slow path cache check below. 606 | if(RKL_EXPECTED(lastCacheSlot != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->options == options, 1L) && RKL_EXPECTED(lastCacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString == (CFStringRef)regexString, 1L)) { 607 | rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(lastCacheSlot - &rkl_cacheSlots[0])][0], lastCacheSlot->options, (int)lastCacheSlot->captureCount, 1, 0, NULL); 608 | return(lastCacheSlot); 609 | } 610 | 611 | lastCacheSlot = NULL; 612 | regexHash = CFHash((CFTypeRef)regexString); 613 | cacheSlot = &rkl_cacheSlots[(regexHash % (CFHashCode)(RKL_CACHE_SIZE))]; // Retrieve the cache slot for this regex. 614 | 615 | // Return the cached entry if it's a match, otherwise clear the slot and create a new ICU regex in its place. 616 | // If regexString is mutable, the pointer equality test will fail, and CFEqual() is used to determine true 617 | // equality with the immutable cacheSlot copy. CFEqual() performs a slow character by character check. 618 | if(RKL_EXPECTED(cacheSlot->options == options, 1L) && RKL_EXPECTED(cacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(cacheSlot->regexString != NULL, 1L) && (RKL_EXPECTED(cacheSlot->regexString == (CFStringRef)regexString, 1L) || RKL_EXPECTED(CFEqual((CFTypeRef)regexString, (CFTypeRef)cacheSlot->regexString) == YES, 1L))) { 619 | lastCacheSlot = cacheSlot; 620 | rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(lastCacheSlot - &rkl_cacheSlots[0])][0], lastCacheSlot->options, (int)lastCacheSlot->captureCount, 1, 0, NULL); 621 | return(cacheSlot); 622 | } 623 | 624 | rkl_clearCacheSlotRegex(cacheSlot); 625 | 626 | if(RKL_EXPECTED((cacheSlot->regexString = CFStringCreateCopy(NULL, (CFStringRef)regexString)) == NULL, 0L)) { goto exitNow; } ; // Get a cheap immutable copy. 627 | rkl_dtrace_getRegexUTF8(cacheSlot->regexString, &rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0]); 628 | cacheSlot->options = options; 629 | 630 | CFIndex regexStringU16Length = CFStringGetLength(cacheSlot->regexString); // In UTF16 code units. 631 | UParseError parseError = (UParseError){-1, -1, {0}, {0}}; 632 | const UniChar *regexUniChar = NULL; 633 | 634 | if(RKL_EXPECTED(regexStringU16Length >= (CFIndex)INT_MAX, 0L)) { *exception = [NSException exceptionWithName:NSRangeException reason:@"Regex string length exceeds INT_MAX" userInfo:NULL]; goto exitNow; } 635 | 636 | // Try to quickly obtain regexString in UTF16 format. 637 | if((regexUniChar = CFStringGetCharactersPtr(cacheSlot->regexString)) == NULL) { // We didn't get the UTF16 pointer quickly and need to perform a full conversion in a temp buffer. 638 | UniChar *uniCharBuffer = NULL; 639 | if(((size_t)regexStringU16Length * sizeof(UniChar)) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)alloca( (size_t)regexStringU16Length * sizeof(UniChar) )) == NULL, 0L)) { goto exitNow; } } // Try to use the stack. 640 | else { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], (size_t)regexStringU16Length * sizeof(UniChar), 0UL)) == NULL, 0L)) { goto exitNow; } } // Otherwise use the heap. 641 | CFStringGetCharacters(cacheSlot->regexString, CFMakeRange(0L, regexStringU16Length), uniCharBuffer); // Convert regexString to UTF16. 642 | regexUniChar = uniCharBuffer; 643 | } 644 | 645 | // Create the ICU regex. 646 | if(RKL_EXPECTED((cacheSlot->icu_regex = RKL_ICU_FUNCTION_APPEND(uregex_open)(regexUniChar, (int32_t)regexStringU16Length, options, &parseError, &status)) == NULL, 0L)) { goto exitNow; } 647 | if(RKL_EXPECTED(status <= U_ZERO_ERROR, 1L)) { cacheSlot->captureCount = (NSInteger)RKL_ICU_FUNCTION_APPEND(uregex_groupCount)(cacheSlot->icu_regex, &status); } 648 | if(RKL_EXPECTED(status <= U_ZERO_ERROR, 1L)) { lastCacheSlot = cacheSlot; } 649 | 650 | exitNow: 651 | if(RKL_EXPECTED(scratchBuffer[0] != NULL, 0L)) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } 652 | if(RKL_EXPECTED(status > U_ZERO_ERROR, 0L)) { rkl_clearCacheSlotRegex(cacheSlot); cacheSlot = NULL; if(error != NULL) { *error = rkl_NSErrorForRegex(regexString, options, &parseError, status); } } 653 | 654 | #ifdef _RKL_DTRACE_ENABLED 655 | if(RKL_EXPECTED(cacheSlot != NULL, 1L)) { rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0], cacheSlot->options, (int)cacheSlot->captureCount, 0, status, NULL); } 656 | else { char regexUTF8[(RKL_DTRACE_REGEXUTF8_SIZE)]; const char *err = NULL; if(status != U_ZERO_ERROR) { err = RKL_ICU_FUNCTION_APPEND(u_errorName)(status); } rkl_dtrace_getRegexUTF8((CFStringRef)regexString, regexUTF8); rkl_dtrace_compiledRegexCache(regexUTF8, options, -1, -1, status, err); } 657 | #endif // _RKL_DTRACE_ENABLED 658 | 659 | return(cacheSlot); 660 | } 661 | 662 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 663 | // IMPORTANT! Should only be called with cacheSpinLock already locked! 664 | // ---------- 665 | 666 | static NSUInteger rkl_setCacheSlotToString(RKLCacheSlot *cacheSlot, const NSRange *range, int32_t *status, id *exception RKL_UNUSED_ASSERTION_ARG) { 667 | RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->setToString != NULL) && ((range != NULL) && (NSEqualRanges(*range, NSNotFoundRange) == NO)) && (status != NULL), exception, exitNow); 668 | const UniChar *stringUniChar = NULL; 669 | #ifdef _RKL_DTRACE_ENABLED 670 | unsigned int lookupResultFlags = 0U; 671 | #endif 672 | 673 | if(cacheSlot->setToNeedsConversion == 0U) { 674 | if(RKL_EXPECTED((stringUniChar = CFStringGetCharactersPtr(cacheSlot->setToString)) == NULL, 0L)) { cacheSlot->setToNeedsConversion = 1U; } 675 | else { if(RKL_EXPECTED(cacheSlot->setToUniChar != stringUniChar, 0L)) { cacheSlot->setToRange = NSNotFoundRange; cacheSlot->setToUniChar = stringUniChar; } goto setRegexText; } 676 | } 677 | rkl_dtrace_addLookupFlag(lookupResultFlags, RKLConversionRequiredLookupFlag); 678 | 679 | NSUInteger useFixedBuffer = (cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? 1UL : 0UL; 680 | RKLBuffer *buffer = useFixedBuffer ? &fixedBuffer : &dynamicBuffer; 681 | rkl_dtrace_addLookupFlag(lookupResultFlags, (useFixedBuffer ? 0U : RKLDynamicBufferLookupFlag)); 682 | 683 | if((buffer->uniChar != NULL) && (cacheSlot->setToString == buffer->string) && (cacheSlot->setToLength == buffer->length) && (cacheSlot->setToHash == buffer->hash)) { rkl_dtrace_addLookupFlag(lookupResultFlags, RKLCacheHitLookupFlag); cacheSlot->setToUniChar = buffer->uniChar; goto setRegexText; } 684 | 685 | if((cacheSlot->setToNeedsConversion == 1U) && RKL_EXPECTED((stringUniChar = CFStringGetCharactersPtr(cacheSlot->setToString)) != NULL, 0L)) { cacheSlot->setToNeedsConversion = 0U; cacheSlot->setToRange = NSNotFoundRange; cacheSlot->setToUniChar = stringUniChar; goto setRegexText; } 686 | 687 | rkl_clearBuffer(buffer, 0UL); 688 | 689 | if(useFixedBuffer == 0U) { 690 | RKLCDelayedAssert(buffer == &dynamicBuffer, exception, exitNow); 691 | RKL_STRONG_REF void *p = (RKL_STRONG_REF void *)dynamicBuffer.uniChar; 692 | if(RKL_EXPECTED((dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)rkl_realloc(&p, ((size_t)cacheSlot->setToLength * sizeof(UniChar)), 0UL)) == NULL, 0L)) { goto exitNow; } // Resize the buffer. 693 | } 694 | 695 | RKLCDelayedAssert(buffer->uniChar != NULL, exception, exitNow); 696 | CFStringGetCharacters(cacheSlot->setToString, CFMakeRange(0L, cacheSlot->setToLength), (UniChar *)buffer->uniChar); // Convert to a UTF16 string. 697 | 698 | RKLCDelayedAssert(buffer->string == NULL, exception, exitNow); 699 | if(RKL_EXPECTED((buffer->string = (CFStringRef)CFRetain((CFTypeRef)cacheSlot->setToString)) == NULL, 0L)) { goto exitNow; } 700 | buffer->hash = cacheSlot->setToHash; 701 | buffer->length = cacheSlot->setToLength; 702 | 703 | cacheSlot->setToUniChar = buffer->uniChar; 704 | cacheSlot->setToRange = NSNotFoundRange; 705 | 706 | setRegexText: 707 | if(NSEqualRanges(cacheSlot->setToRange, *range) == NO) { 708 | RKLCDelayedAssert((cacheSlot->icu_regex != NULL) && (cacheSlot->setToUniChar != NULL) && (NSMaxRange(*range) <= (NSUInteger)cacheSlot->setToLength) && (cacheSlot->setToRange.length <= INT_MAX), exception, exitNow); 709 | cacheSlot->lastFindRange = cacheSlot->lastMatchRange = NSNotFoundRange; 710 | cacheSlot->setToRange = *range; 711 | RKL_ICU_FUNCTION_APPEND(uregex_setText)(cacheSlot->icu_regex, cacheSlot->setToUniChar + cacheSlot->setToRange.location, (int32_t)cacheSlot->setToRange.length, status); 712 | rkl_dtrace_addLookupFlag(lookupResultFlags, RKLSetTextLookupFlag); 713 | if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto exitNow; } 714 | } 715 | 716 | rkl_dtrace_utf16ConversionCache(lookupResultFlags, cacheSlot->setToString, cacheSlot->setToRange.location, cacheSlot->setToRange.length, cacheSlot->setToLength); 717 | return(1UL); 718 | 719 | exitNow: 720 | return(0UL); 721 | } 722 | 723 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 724 | // IMPORTANT! Should only be called with cacheSpinLock already locked! 725 | // ---------- 726 | 727 | static RKLCacheSlot *rkl_getCachedRegexSetToString(NSString *regexString, RKLRegexOptions options, NSString *matchString, NSUInteger *matchLengthPtr, NSRange *matchRange, NSError **error, id *exception, int32_t *status) { 728 | RKLCacheSlot *cacheSlot = NULL; 729 | RKLCDelayedAssert((regexString != NULL) && (exception != NULL) && (status != NULL) && (matchLengthPtr != NULL), exception, exitNow); 730 | 731 | // Fast path the common case where this regex is exactly the same one used last time. 732 | if(RKL_EXPECTED(lastCacheSlot != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString == (CFStringRef)regexString, 1L) && RKL_EXPECTED(lastCacheSlot->options == options, 1L)) { cacheSlot = lastCacheSlot; rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0], cacheSlot->options, (int)cacheSlot->captureCount, 1, 0, NULL); } 733 | else { lastCacheSlot = NULL; if(RKL_EXPECTED((cacheSlot = rkl_getCachedRegex(regexString, options, error, exception)) == NULL, 0L)) { goto exitNow; } } 734 | RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->regexString != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot == lastCacheSlot), exception, exitNow); 735 | 736 | // Optimize the case where the string to search (matchString) is immutable and the setToString immutable copy is the same string with its reference count incremented. 737 | NSUInteger isSetTo = ((cacheSlot->setToString != NULL) && (cacheSlot->setToString == (CFStringRef)matchString)) ? 1UL : 0UL; 738 | CFIndex matchLength = ((isSetTo == 1UL) && (cacheSlot->setToIsImmutable == 1U)) ? cacheSlot->setToLength : CFStringGetLength((CFStringRef)matchString); 739 | 740 | *matchLengthPtr = (NSUInteger)matchLength; 741 | if(matchRange->length == NSUIntegerMax) { matchRange->length = (NSUInteger)matchLength; } // For convenience, allow NSUIntegerMax == string length. 742 | 743 | if(RKL_EXPECTED((NSUInteger)matchLength < NSMaxRange(*matchRange), 0L)) { goto exitNow; } // The match range is out of bounds for the string. performRegexOp will catch and report the problem. 744 | 745 | if((isSetTo == 1UL) && (cacheSlot->setToIsImmutable == 0U) && (cacheSlot->setToString != NULL) && ((cacheSlot->setToLength != CFStringGetLength(cacheSlot->setToString)) || (cacheSlot->setToHash != CFHash((CFTypeRef)cacheSlot->setToString)))) { isSetTo = 0UL; } 746 | else { // If the first pointer equality check failed, check the hash and length. 747 | if(((isSetTo == 0UL) || (cacheSlot->setToIsImmutable == 0U)) && (cacheSlot->setToString != NULL)) { isSetTo = ((cacheSlot->setToString == (CFStringRef)matchString) && (cacheSlot->setToLength == matchLength) && (cacheSlot->setToHash == CFHash((CFTypeRef)matchString))) ? 1UL : 0UL; } 748 | 749 | if(isSetTo == 1UL) { if(RKL_EXPECTED(rkl_setCacheSlotToString(cacheSlot, matchRange, status, exception) == 0UL, 0L)) { cacheSlot = NULL; if(*exception == NULL) { *exception = (id)RKLCAssertDictionary(@"Failed to set up UTF16 buffer."); } } goto exitNow; } 750 | } 751 | 752 | // Sometimes the range that the regex is set to isn't right, in which case we don't want to clear the cache slot. Otherwise, flush it out. 753 | if((cacheSlot->setToString != NULL) && (isSetTo == 0UL)) { rkl_clearCacheSlotSetTo(cacheSlot); } 754 | 755 | if(cacheSlot->setToString == NULL) { 756 | cacheSlot->setToString = (CFStringRef)CFRetain((CFTypeRef)matchString); 757 | RKLCDelayedAssert(cacheSlot->setToString != NULL, exception, exitNow); 758 | cacheSlot->setToUniChar = CFStringGetCharactersPtr(cacheSlot->setToString); 759 | cacheSlot->setToNeedsConversion = (cacheSlot->setToUniChar == NULL) ? 1U : 0U; 760 | cacheSlot->setToIsImmutable = (rkl_CFStringIsMutable(cacheSlot->setToString) == YES) ? 0U : 1U; // If RKL_FAST_MUTABLE_CHECK is not defined then setToIsImmutable will always be set to '0', or in other words mutable.. 761 | cacheSlot->setToHash = CFHash((CFTypeRef)cacheSlot->setToString); 762 | cacheSlot->setToRange = NSNotFoundRange; 763 | cacheSlot->setToLength = matchLength; 764 | } 765 | 766 | if(RKL_EXPECTED(rkl_setCacheSlotToString(cacheSlot, matchRange, status, exception) == 0UL, 0L)) { cacheSlot = NULL; if(*exception == NULL) { *exception = (id)RKLCAssertDictionary(@"Failed to set up UTF16 buffer."); } goto exitNow; } 767 | 768 | exitNow: 769 | return(cacheSlot); 770 | } 771 | 772 | #ifdef RKL_HAVE_CLEANUP 773 | 774 | // rkl_cleanup_cacheSpinLockStatus takes advantage of GCC's 'cleanup' variable attribute. When an 'auto' variable with the 'cleanup' attribute goes out of scope, 775 | // GCC arranges to have the designated function called. In this case, we make sure that if rkl_cacheSpinLock was locked that it was also unlocked. 776 | // If rkl_cacheSpinLock was locked, but the cacheSpinLockStatus unlocked flag was not set, we force cacheSpinLock unlocked with a call to OSSpinLockUnlock. 777 | // This is not a panacea for preventing mutex usage errors. Old style ObjC exceptions will bypass the cleanup call, but newer C++ style ObjC exceptions should cause the cleanup function to be called during the stack unwind. 778 | 779 | // We do not depend on this cleanup function being called. It is used only as an extra safety net. It is probably a bug in RegexKitLite if it is ever invoked and forced to take some kind of protective action. 780 | 781 | volatile NSUInteger rkl_debugCacheSpinLockCount = 0UL; 782 | 783 | void rkl_debugCacheSpinLock (void) RKL_ATTRIBUTES(used, noinline, visibility("default")); 784 | static void rkl_cleanup_cacheSpinLockStatus (volatile NSUInteger *cacheSpinLockStatusPtr) RKL_ATTRIBUTES(used); 785 | 786 | void rkl_debugCacheSpinLock(void) { 787 | rkl_debugCacheSpinLockCount++; // This is here primarily to prevent the optimizer from optimizing away the function. 788 | } 789 | 790 | static void rkl_cleanup_cacheSpinLockStatus(volatile NSUInteger *cacheSpinLockStatusPtr) { 791 | static NSUInteger didPrintForcedUnlockWarning = 0UL, didPrintNotLockedWarning = 0UL; 792 | NSUInteger cacheSpinLockStatus = *cacheSpinLockStatusPtr; 793 | 794 | if(RKL_EXPECTED((cacheSpinLockStatus & RKLUnlockedCacheSpinLock) == 0UL, 0L) && RKL_EXPECTED((cacheSpinLockStatus & RKLLockedCacheSpinLock) != 0UL, 1L)) { 795 | if(cacheSpinLock != (OSSpinLock)0) { 796 | if(didPrintForcedUnlockWarning == 0UL) { didPrintForcedUnlockWarning = 1UL; NSLog(@"[RegexKitLite] Unusual condition detected: Recorded that cacheSpinLock was locked, but for some reason it was not unlocked. Forcibly unlocking cacheSpinLock. Set a breakpoint at rkl_debugCacheSpinLock to debug. This warning is only printed once."); } 797 | rkl_debugCacheSpinLock(); // Since this is an unusual condition, offer an attempt to catch it before we unlock. 798 | OSSpinLockUnlock(&cacheSpinLock); 799 | } else { 800 | if(didPrintNotLockedWarning == 0UL) { didPrintNotLockedWarning = 1UL; NSLog(@"[RegexKitLite] Unusual condition detected: Recorded that cacheSpinLock was locked, but for some reason it was not unlocked, yet cacheSpinLock is currently not locked? Set a breakpoint at rkl_debugCacheSpinLock to debug. This warning is only printed once."); } 801 | rkl_debugCacheSpinLock(); 802 | } 803 | } 804 | } 805 | 806 | #endif // RKL_HAVE_CLEANUP 807 | 808 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 809 | // ---------- 810 | 811 | static id rkl_performRegexOp(id self, SEL _cmd, RKLRegexOp regexOp, NSString *regexString, RKLRegexOptions options, NSInteger capture, id matchString, NSRange *matchRange, NSString *replacementString, NSError **error, void *result) { 812 | volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; 813 | 814 | NSUInteger replaceMutable = 0UL; 815 | RKLRegexOp maskedRegexOp = (regexOp & RKLMaskOp); 816 | 817 | if((error != NULL) && (*error != NULL)) { *error = NULL; } 818 | 819 | if(RKL_EXPECTED(regexString == NULL, 0L)) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The regular expression argument is NULL."); } 820 | if(RKL_EXPECTED(matchString == NULL, 0L)) { RKL_RAISE_EXCEPTION(NSInternalInconsistencyException, @"The match string argument is NULL."); } 821 | if((maskedRegexOp == RKLReplaceOp) && (replacementString == NULL)) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The replacement string argument is NULL."); } 822 | 823 | id resultObject = NULL, exception = NULL; 824 | int32_t status = U_ZERO_ERROR; 825 | RKLCacheSlot *cacheSlot = NULL; 826 | NSUInteger stringU16Length = 0UL; 827 | NSRange stackRanges[2048]; 828 | RKLFindAll findAll; 829 | 830 | 831 | // IMPORTANT! Once we have obtained the lock, code MUST exit via 'goto exitNow;' to unlock the lock! NO EXCEPTIONS! 832 | // ---------- 833 | OSSpinLockLock(&cacheSpinLock); // Grab the lock and get cache entry. 834 | cacheSpinLockStatus |= RKLLockedCacheSpinLock; 835 | rkl_dtrace_incrementEventID(); 836 | 837 | if(RKL_EXPECTED((cacheSlot = rkl_getCachedRegexSetToString(regexString, options, matchString, &stringU16Length, matchRange, error, &exception, &status)) == NULL, 0L)) { stringU16Length = (NSUInteger)CFStringGetLength((CFStringRef)matchString); } 838 | if(RKL_EXPECTED(matchRange->length == NSUIntegerMax, 1L)) { matchRange->length = stringU16Length; } // For convenience. 839 | if(RKL_EXPECTED(stringU16Length < NSMaxRange(*matchRange), 0L) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSRangeException, @"Range or index out of bounds."); goto exitNow; } 840 | if(RKL_EXPECTED(stringU16Length >= (NSUInteger)INT_MAX, 0L) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSRangeException, @"String length exceeds INT_MAX."); goto exitNow; } 841 | if(((maskedRegexOp == RKLRangeOp) || (maskedRegexOp == RKLArrayOfStringsOp)) && RKL_EXPECTED(cacheSlot != NULL, 1L) && (RKL_EXPECTED(capture < 0L, 0L) || RKL_EXPECTED(capture > cacheSlot->captureCount, 0L)) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSInvalidArgumentException, @"The capture argument is not valid."); goto exitNow; } 842 | if(RKL_EXPECTED(cacheSlot == NULL, 0L) || RKL_EXPECTED(status > U_ZERO_ERROR, 0L) || RKL_EXPECTED(exception != NULL, 0L)) { goto exitNow; } 843 | 844 | RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->regexString != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot->setToString != NULL) && (cacheSlot->setToLength >= 0L) && (cacheSlot->setToUniChar != NULL) && ((CFIndex)NSMaxRange(cacheSlot->setToRange) <= cacheSlot->setToLength), &exception, exitNow); 845 | 846 | #ifndef NS_BLOCK_ASSERTIONS 847 | if(cacheSlot->setToNeedsConversion == 0U) { RKLCDelayedAssert((cacheSlot->setToUniChar == CFStringGetCharactersPtr(cacheSlot->setToString)), &exception, exitNow); } 848 | else { 849 | RKLBuffer *buffer = (cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer; 850 | RKLCDelayedAssert((cacheSlot->setToHash == buffer->hash) && (cacheSlot->setToLength == buffer->length) && (cacheSlot->setToUniChar == buffer->uniChar), &exception, exitNow); 851 | } 852 | #endif 853 | 854 | switch(maskedRegexOp) { 855 | case RKLRangeOp: 856 | if((rkl_search(cacheSlot, matchRange, 0UL, &exception, &status) == NO) || (RKL_EXPECTED(status > U_ZERO_ERROR, 0L))) { *(NSRange *)result = NSNotFoundRange; goto exitNow; } 857 | if(RKL_EXPECTED(capture == 0L, 1L)) { *(NSRange *)result = cacheSlot->lastMatchRange; } else { if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, &status, (int32_t)capture, (NSRange *)result) > U_ZERO_ERROR, 0L)) { goto exitNow; } } 858 | break; 859 | 860 | case RKLSplitOp: // Fall-thru... 861 | case RKLArrayOfStringsOp: // Fall-thru... 862 | case RKLCapturesArrayOp: // Fall-thru... 863 | case RKLArrayOfCapturesOp: 864 | findAll = rkl_makeFindAll(stackRanges, *matchRange, 2048L, (2048UL * sizeof(NSRange)), 0UL, (void **)&scratchBuffer[0], &scratchBuffer[1], &scratchBuffer[2], 0L, capture, ((maskedRegexOp == RKLCapturesArrayOp) ? 1L : NSIntegerMax)); 865 | 866 | if(RKL_EXPECTED(rkl_findRanges(cacheSlot, regexOp, &findAll, &exception, &status) == NO, 1L)) { 867 | if(RKL_EXPECTED(findAll.found == 0L, 0L)) { resultObject = [NSArray array]; } else { resultObject = rkl_makeArray(cacheSlot, regexOp, &findAll, &exception); } 868 | } 869 | 870 | if(RKL_EXPECTED(scratchBuffer[0] != NULL, 0L)) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } 871 | if(RKL_EXPECTED(scratchBuffer[1] != NULL, 0L)) { scratchBuffer[1] = rkl_free(&scratchBuffer[1]); } 872 | if(RKL_EXPECTED(scratchBuffer[2] != NULL, 0L)) { scratchBuffer[2] = rkl_free(&scratchBuffer[2]); } 873 | 874 | break; 875 | 876 | case RKLReplaceOp: resultObject = rkl_replaceString(cacheSlot, matchString, stringU16Length, replacementString, (NSUInteger)CFStringGetLength((CFStringRef)replacementString), (NSUInteger *)result, (replaceMutable = (((regexOp & RKLReplaceMutable) != 0) ? 1UL : 0UL)), &exception, &status); break; 877 | default: exception = RKLCAssertDictionary(@"Unknown regexOp code."); break; 878 | } 879 | 880 | exitNow: 881 | OSSpinLockUnlock(&cacheSpinLock); 882 | cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. 883 | 884 | if(RKL_EXPECTED(status > U_ZERO_ERROR, 0L) && RKL_EXPECTED(exception == NULL, 0L)) { exception = rkl_NSExceptionForRegex(regexString, options, NULL, status); } // If we had a problem, prepare an exception to be thrown. 885 | if(RKL_EXPECTED(exception != NULL, 0L)) { rkl_handleDelayedAssert(self, _cmd, exception); } // If there is an exception, throw it at this point. 886 | // If we're working on a mutable string and there were successful matches/replacements, then we still have work to do. 887 | // This is done outside the cache lock and with the objc replaceCharactersInRange:withString: method because Core Foundation 888 | // does not assert that the string we are attempting to update is actually a mutable string, whereas Foundation ensures 889 | // the object receiving the message is a mutable string and throws an exception if we're attempting to modify an immutable string. 890 | if(RKL_EXPECTED(status == U_ZERO_ERROR, 1L) && RKL_EXPECTED(resultObject != NULL, 1L) && RKL_EXPECTED(replaceMutable == 1UL, 0L) && RKL_EXPECTED(*((NSUInteger *)result) > 0UL, 1L)) { [matchString replaceCharactersInRange:*matchRange withString:resultObject]; } 891 | // If status < U_ZERO_ERROR, consider it an error, even though status < U_ZERO_ERROR is a 'warning' in ICU nomenclature. 892 | // status > U_ZERO_ERROR are an exception and handled above. 893 | // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 894 | if(RKL_EXPECTED(status < U_ZERO_ERROR, 0L) && RKL_EXPECTED(resultObject == NULL, 0L) && (error != NULL)) { *error = [NSError errorWithDomain:RKLICURegexErrorDomain code:(NSInteger)status userInfo:rkl_userInfoDictionary(regexString, options, NULL, status, @"The ICU library returned an unexpected error code.", @"NSLocalizedDescription", NULL)]; } 895 | return(resultObject); 896 | } 897 | 898 | static void rkl_handleDelayedAssert(id self, SEL _cmd, id exception) { 899 | if(RKL_EXPECTED(exception != NULL, 0L)) { 900 | if([exception isKindOfClass:[NSException class]]) { [[NSException exceptionWithName:[exception name] reason:rkl_stringFromClassAndMethod(self, _cmd, [exception reason]) userInfo:[exception userInfo]] raise]; } 901 | else { 902 | id functionString = [exception objectForKey:@"function"], fileString = [exception objectForKey:@"file"], descriptionString = [exception objectForKey:@"description"], lineNumber = [exception objectForKey:@"line"]; 903 | NSCParameterAssert((functionString != NULL) && (fileString != NULL) && (descriptionString != NULL) && (lineNumber != NULL)); 904 | [[NSAssertionHandler currentHandler] handleFailureInFunction:functionString file:fileString lineNumber:(NSInteger)[lineNumber longValue] description:descriptionString]; 905 | } 906 | } 907 | } 908 | 909 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 910 | // IMPORTANT! Should only be called from rkl_performRegexOp() or rkl_findRanges(). 911 | // ---------- 912 | 913 | static NSUInteger rkl_search(RKLCacheSlot *cacheSlot, NSRange *searchRange, NSUInteger updateSearchRange, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) { 914 | NSUInteger foundMatch = 0UL, searchEqualsEndOfRange = (RKL_EXPECTED(NSEqualRanges(*searchRange, NSMakeRange(NSMaxRange(cacheSlot->setToRange), 0UL)) == YES, 0L) ? 1UL : 0UL); 915 | 916 | if((NSEqualRanges(*searchRange, cacheSlot->lastFindRange) == YES) || (searchEqualsEndOfRange == 1UL)) { foundMatch = (((cacheSlot->lastMatchRange.location == (NSUInteger)NSNotFound) || (searchEqualsEndOfRange == 1UL)) ? 0UL : 1UL);} 917 | else { // Only perform an expensive 'find' operation iff the current find range is different than the last find range. 918 | NSUInteger findLocation = (searchRange->location - cacheSlot->setToRange.location); 919 | RKLCDelayedAssert(((searchRange->location >= cacheSlot->setToRange.location)) && (NSRangeInsideRange(*searchRange, cacheSlot->setToRange) == YES) && (findLocation < INT_MAX) && (findLocation <= cacheSlot->setToRange.length), exception, exitNow); 920 | 921 | RKL_PREFETCH_UNICHAR(cacheSlot->setToUniChar, searchRange->location); // Spool up the CPU caches. 922 | 923 | // Using uregex_findNext can be a slight performance win. 924 | NSUInteger useFindNext = ((searchRange->location == (NSMaxRange(cacheSlot->lastMatchRange) + (((cacheSlot->lastMatchRange.length == 0UL) && (cacheSlot->lastMatchRange.location < NSMaxRange(cacheSlot->setToRange))) ? 1UL : 0UL))) ? 1UL : 0UL); 925 | 926 | cacheSlot->lastFindRange = *searchRange; 927 | if(RKL_EXPECTED(useFindNext == 0UL, 0L)) { if(RKL_EXPECTED((RKL_ICU_FUNCTION_APPEND(uregex_find) (cacheSlot->icu_regex, (int32_t)findLocation, status) == NO), 0L) || RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto finishedFind; } } 928 | else { if(RKL_EXPECTED((RKL_ICU_FUNCTION_APPEND(uregex_findNext)(cacheSlot->icu_regex, status) == NO), 0L) || RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto finishedFind; } } 929 | foundMatch = 1UL; 930 | 931 | if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, 0, &cacheSlot->lastMatchRange) > U_ZERO_ERROR, 0L)) { goto finishedFind; } 932 | RKLCDelayedAssert(NSRangeInsideRange(cacheSlot->lastMatchRange, *searchRange) == YES, exception, exitNow); 933 | } 934 | 935 | finishedFind: 936 | if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { foundMatch = 0UL; cacheSlot->lastFindRange = NSNotFoundRange; } 937 | 938 | if(foundMatch == 0UL) { cacheSlot->lastFindRange = NSNotFoundRange; cacheSlot->lastMatchRange = NSNotFoundRange; if(updateSearchRange == 1UL) { *searchRange = NSMakeRange(NSMaxRange(*searchRange), 0UL); } } 939 | else { 940 | RKLCDelayedAssert(NSRangeInsideRange(cacheSlot->lastMatchRange, *searchRange) == YES, exception, exitNow); 941 | if(updateSearchRange == 1UL) { 942 | NSUInteger nextLocation = (NSMaxRange(cacheSlot->lastMatchRange) + (((cacheSlot->lastMatchRange.length == 0UL) && (cacheSlot->lastMatchRange.location < NSMaxRange(cacheSlot->setToRange))) ? 1UL : 0UL)), locationDiff = nextLocation - searchRange->location; 943 | RKLCDelayedAssert((((locationDiff > 0UL) || ((locationDiff == 0UL) && (cacheSlot->lastMatchRange.location == NSMaxRange(cacheSlot->setToRange)))) && (locationDiff <= searchRange->length)), exception, exitNow); 944 | searchRange->location = nextLocation; 945 | searchRange->length -= locationDiff; 946 | } 947 | } 948 | 949 | #ifndef NS_BLOCK_ASSERTIONS 950 | exitNow: 951 | #endif 952 | return(foundMatch); 953 | } 954 | 955 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 956 | // IMPORTANT! Should only be called from rkl_doFindOp(). 957 | // ---------- 958 | 959 | static BOOL rkl_findRanges(RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception, int32_t *status) { 960 | BOOL returnWithError = YES; 961 | RKLCDelayedAssert((((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->setToUniChar != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot->setToRange.location != (NSUInteger)NSNotFound)) && (status != NULL) && ((findAll != NULL) && (findAll->found == 0L) && ((findAll->capacity >= 0L) && (((findAll->capacity > 0L) || (findAll->size > 0UL)) ? ((findAll->ranges != NULL) && (findAll->capacity > 0L) && (findAll->size > 0UL)) : 1)) && (findAll->rangesScratchBuffer != NULL) && ((findAll->capture >= 0L) && (findAll->capture <= cacheSlot->captureCount)))), exception, exitNow); 962 | 963 | if(RKL_EXPECTED(cacheSlot->setToLength == 0L, 0L) || RKL_EXPECTED(cacheSlot->setToRange.length == 0UL, 0L)) { returnWithError = NO; goto exitNow; } 964 | 965 | NSInteger captureCount = cacheSlot->captureCount; 966 | RKLRegexOp maskedRegexOp = (regexOp & RKLMaskOp); 967 | NSUInteger lastLocation = findAll->findInRange.location; 968 | NSRange searchRange = findAll->findInRange; 969 | 970 | for(findAll->found = 0L; (findAll->found < findAll->findUpTo) && ((findAll->found < findAll->capacity) || (findAll->found == 0L)); findAll->found++) { 971 | NSInteger loopCapture, shouldBreak = 0L; 972 | 973 | if(RKL_EXPECTED(findAll->found >= ((findAll->capacity - ((captureCount + 2L) * 4L)) - 4L), 0L)) { if(RKL_EXPECTED(rkl_growFindRanges(cacheSlot, lastLocation, findAll, exception) == 0UL, 0L)) { goto exitNow; } } 974 | 975 | RKLCDelayedAssert((searchRange.location != (NSUInteger)NSNotFound) && (NSRangeInsideRange(searchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(findAll->findInRange, cacheSlot->setToRange) == YES), exception, exitNow); 976 | 977 | // This fixes a 'bug' that is also present in ICU's uregex_split(). 'Bug', in this case, means that the results of a split operation can differ from those that perl's split() creates for the same input. 978 | // "I|at|ice I eat rice" split using the regex "\b\s*" demonstrates the problem. ICU bug http://bugs.icu-project.org/trac/ticket/6826 979 | // ICU : "", "I", "|", "at", "|", "ice", "", "I", "", "eat", "", "rice" <- Results that RegexKitLite used to produce. 980 | // PERL: "I", "|", "at", "|", "ice", "I", "eat", "rice" <- Results that RegexKitLite now produces. 981 | do { if((rkl_search(cacheSlot, &searchRange, 1UL, exception, status) == NO) || (RKL_EXPECTED(*status > U_ZERO_ERROR, 0L))) { shouldBreak = 1L; } } 982 | while((maskedRegexOp == RKLSplitOp) && RKL_EXPECTED(shouldBreak == 0L, 1L) && RKL_EXPECTED(cacheSlot->lastMatchRange.length == 0UL, 0L) && RKL_EXPECTED((cacheSlot->lastMatchRange.location - lastLocation) == 0UL, 0L)); 983 | if(RKL_EXPECTED(shouldBreak == 1L, 0L)) { break; } 984 | 985 | RKLCDelayedAssert((searchRange.location != (NSUInteger)NSNotFound) && (NSRangeInsideRange(searchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(findAll->findInRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(searchRange, findAll->findInRange) == YES), exception, exitNow); 986 | RKLCDelayedAssert((NSRangeInsideRange(cacheSlot->lastFindRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(cacheSlot->lastMatchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(cacheSlot->lastMatchRange, findAll->findInRange) == YES), exception, exitNow); 987 | RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->capacity >= 0L) && ((findAll->found + (captureCount + 3L) + 1L) < (findAll->capacity - 2L)), exception, exitNow); 988 | 989 | switch(maskedRegexOp) { 990 | case RKLArrayOfStringsOp: 991 | if(findAll->capture == 0L) { findAll->ranges[findAll->found] = cacheSlot->lastMatchRange; } else { if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, (int32_t)findAll->capture, &findAll->ranges[findAll->found]) > U_ZERO_ERROR, 0L)) { goto exitNow; } } 992 | break; 993 | 994 | case RKLSplitOp: // Fall-thru... 995 | case RKLCapturesArrayOp: // Fall-thru... 996 | case RKLArrayOfCapturesOp: 997 | findAll->ranges[findAll->found] = ((maskedRegexOp == RKLSplitOp) ? NSMakeRange(lastLocation, cacheSlot->lastMatchRange.location - lastLocation) : cacheSlot->lastMatchRange); 998 | 999 | for(loopCapture = 1L; loopCapture <= captureCount; loopCapture++) { 1000 | RKLCDelayedAssert((findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)) && (loopCapture < INT_MAX), exception, exitNow); 1001 | if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, (int32_t)loopCapture, &findAll->ranges[++findAll->found]) > U_ZERO_ERROR, 0L)) { goto exitNow; } 1002 | } 1003 | break; 1004 | 1005 | default: if(*exception != NULL) { *exception = RKLCAssertDictionary(@"Unknown regexOp."); } goto exitNow; break; 1006 | } 1007 | 1008 | lastLocation = NSMaxRange(cacheSlot->lastMatchRange); 1009 | } 1010 | 1011 | if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto exitNow; } 1012 | 1013 | RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)), exception, exitNow); 1014 | if((maskedRegexOp == RKLSplitOp) && (lastLocation != NSMaxRange(findAll->findInRange))) { findAll->ranges[findAll->found++] = NSMakeRange(lastLocation, NSMaxRange(findAll->findInRange) - lastLocation); } 1015 | 1016 | RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)), exception, exitNow); 1017 | returnWithError = NO; 1018 | 1019 | exitNow: 1020 | return(returnWithError); 1021 | } 1022 | 1023 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 1024 | // IMPORTANT! Should only be called from rkl_findRanges(). 1025 | // ---------- 1026 | 1027 | static NSUInteger rkl_growFindRanges(RKLCacheSlot *cacheSlot, NSUInteger lastLocation, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) { 1028 | NSUInteger didGrowRanges = 0UL; 1029 | RKLCDelayedAssert((((cacheSlot != NULL) && (cacheSlot->captureCount >= 0L)) && ((findAll != NULL) && (findAll->capacity >= 0L) && (findAll->rangesScratchBuffer != NULL) && (findAll->found >= 0L) && (((findAll->capacity > 0L) || (findAll->size > 0UL) || (findAll->ranges != NULL)) ? ((findAll->capacity > 0L) && (findAll->size > 0UL) && (findAll->ranges != NULL) && (((size_t)findAll->capacity * sizeof(NSRange)) == findAll->size)) : 1))), exception, exitNow); 1030 | 1031 | // Attempt to guesstimate the required capacity based on: the total length needed to search / (length we've searched so far / ranges found so far). 1032 | NSInteger newCapacity = (findAll->capacity + (findAll->capacity / 2L)), estimate = (NSInteger)((float)cacheSlot->setToLength / (((float)lastLocation + 1.0f) / ((float)findAll->found + 1.0f))); 1033 | newCapacity = (((newCapacity + ((estimate > newCapacity) ? estimate : newCapacity)) / 2L) + ((cacheSlot->captureCount + 2L) * 4L) + 4L); 1034 | 1035 | NSUInteger needToCopy = ((findAll->ranges != NULL) && (*findAll->rangesScratchBuffer != findAll->ranges)) ? 1UL : 0UL; // If findAll->ranges is set to a stack allocation then we need to manually copy the data from the stack to the new heap allocation. 1036 | size_t newSize = ((size_t)newCapacity * sizeof(NSRange)); 1037 | NSRange *newRanges = NULL; 1038 | 1039 | if(RKL_EXPECTED((newRanges = (NSRange *)rkl_realloc((RKL_STRONG_REF void **)findAll->rangesScratchBuffer, newSize, 0UL)) == NULL, 0L)) { findAll->capacity = 0L; findAll->size = 0UL; findAll->ranges = NULL; *findAll->rangesScratchBuffer = rkl_free((RKL_STRONG_REF void **)findAll->rangesScratchBuffer); goto exitNow; } else { didGrowRanges = 1UL; } 1040 | if(needToCopy == 1UL) { memcpy(newRanges, findAll->ranges, findAll->size); } // If necessary, copy the existing data to the new heap allocation. 1041 | 1042 | findAll->capacity = newCapacity; 1043 | findAll->size = newSize; 1044 | findAll->ranges = newRanges; 1045 | 1046 | exitNow: 1047 | return(didGrowRanges); 1048 | } 1049 | 1050 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 1051 | // IMPORTANT! Should only be called from rkl_doFindOp(). 1052 | // ---------- 1053 | 1054 | static NSArray *rkl_makeArray(RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) { 1055 | NSUInteger createdStringsCount = 0UL, createdArraysCount = 0UL, transferedStringsCount = 0UL; 1056 | id *matchedStrings = NULL, *subcaptureArrays = NULL, emptyString = @""; 1057 | NSArray *resultArray = NULL; 1058 | 1059 | RKLCDelayedAssert((cacheSlot != NULL) && ((findAll != NULL) && (findAll->found >= 0L) && (findAll->stringsScratchBuffer != NULL) && (findAll->arraysScratchBuffer != NULL)), exception, exitNow); 1060 | 1061 | size_t matchedStringsSize = ((size_t)findAll->found * sizeof(id)); 1062 | CFStringRef setToString = cacheSlot->setToString; 1063 | 1064 | if((findAll->stackUsed + matchedStringsSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((matchedStrings = (id *)alloca(matchedStringsSize)) == NULL, 0L)) { goto exitNow; } findAll->stackUsed += matchedStringsSize; } 1065 | else { if(RKL_EXPECTED((matchedStrings = (id *)rkl_realloc(findAll->stringsScratchBuffer, matchedStringsSize, (NSUInteger)RKLScannedOption)) == NULL, 0L)) { goto exitNow; } } 1066 | 1067 | { // This sub-block (and its local variables) is here for the benefit of the optimizer. 1068 | NSUInteger found = (NSUInteger)findAll->found; 1069 | const NSRange *rangePtr = findAll->ranges; 1070 | id *matchedStringsPtr = matchedStrings; 1071 | 1072 | for(createdStringsCount = 0UL; createdStringsCount < found; createdStringsCount++) { 1073 | NSRange range = *rangePtr++; 1074 | if(RKL_EXPECTED(((*matchedStringsPtr++ = RKL_EXPECTED(range.length == 0UL, 0L) ? emptyString : rkl_CreateStringWithSubstring((id)setToString, range)) == NULL), 0L)) { goto exitNow; } 1075 | } 1076 | } 1077 | 1078 | NSUInteger arrayCount = createdStringsCount; 1079 | id *arrayObjects = matchedStrings; 1080 | 1081 | if((regexOp & RKLSubcapturesArray) != 0UL) { 1082 | RKLCDelayedAssert(((createdStringsCount % ((NSUInteger)cacheSlot->captureCount + 1UL)) == 0UL) && (createdArraysCount == 0UL), exception, exitNow); 1083 | 1084 | NSUInteger captureCount = ((NSUInteger)cacheSlot->captureCount + 1UL); 1085 | NSUInteger subcaptureArraysCount = (createdStringsCount / captureCount); 1086 | size_t subcaptureArraysSize = ((size_t)subcaptureArraysCount * sizeof(id)); 1087 | 1088 | if((findAll->stackUsed + subcaptureArraysSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((subcaptureArrays = (id *)alloca(subcaptureArraysSize)) == NULL, 0L)) { goto exitNow; } findAll->stackUsed += subcaptureArraysSize; } 1089 | else { if(RKL_EXPECTED((subcaptureArrays = (id *)rkl_realloc(findAll->arraysScratchBuffer, subcaptureArraysSize, (NSUInteger)RKLScannedOption)) == NULL, 0L)) { goto exitNow; } } 1090 | 1091 | { // This sub-block (and its local variables) is here for the benefit of the optimizer. 1092 | id *subcaptureArraysPtr = subcaptureArrays; 1093 | id *matchedStringsPtr = matchedStrings; 1094 | 1095 | for(createdArraysCount = 0UL; createdArraysCount < subcaptureArraysCount; createdArraysCount++) { 1096 | if(RKL_EXPECTED((*subcaptureArraysPtr++ = rkl_CreateArrayWithObjects((void **)matchedStringsPtr, captureCount)) == NULL, 0L)) { goto exitNow; } 1097 | matchedStringsPtr += captureCount; 1098 | transferedStringsCount += captureCount; 1099 | } 1100 | } 1101 | 1102 | RKLCDelayedAssert((transferedStringsCount == createdStringsCount), exception, exitNow); 1103 | arrayCount = createdArraysCount; 1104 | arrayObjects = subcaptureArrays; 1105 | } 1106 | 1107 | RKLCDelayedAssert((arrayObjects != NULL), exception, exitNow); 1108 | resultArray = rkl_CreateAutoreleasedArray((void **)arrayObjects, (NSUInteger)arrayCount); 1109 | 1110 | exitNow: 1111 | if(RKL_EXPECTED(resultArray == NULL, 0L) && (rkl_collectingEnabled() == NO)) { // If we did not create an array then we need to make sure that we release any objects we created. 1112 | NSUInteger x; 1113 | if(matchedStrings != NULL) { for(x = transferedStringsCount; x < createdStringsCount; x++) { if((matchedStrings[x] != NULL) && (matchedStrings[x] != emptyString)) { matchedStrings[x] = rkl_ReleaseObject(matchedStrings[x]); } } } 1114 | if(subcaptureArrays != NULL) { for(x = 0UL; x < createdArraysCount; x++) { if(subcaptureArrays[x] != NULL) { subcaptureArrays[x] = rkl_ReleaseObject(subcaptureArrays[x]); } } } 1115 | } 1116 | 1117 | return(resultArray); 1118 | } 1119 | 1120 | // IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. 1121 | // IMPORTANT! Should only be called from rkl_performRegexOp(). 1122 | // ---------- 1123 | 1124 | static NSString *rkl_replaceString(RKLCacheSlot *cacheSlot, id searchString, NSUInteger searchU16Length, NSString *replacementString, NSUInteger replacementU16Length, NSUInteger *replacedCountPtr, NSUInteger replaceMutable, id *exception, int32_t *status) { 1125 | uint64_t searchU16Length64 = (uint64_t)searchU16Length, replacementU16Length64 = (uint64_t)replacementU16Length; 1126 | int32_t resultU16Length = 0, tempUniCharBufferU16Capacity = 0, needU16Capacity = 0; 1127 | UniChar *tempUniCharBuffer = NULL; 1128 | const UniChar *replacementUniChar = NULL; 1129 | id resultObject = NULL; 1130 | NSUInteger replacedCount = 0UL; 1131 | 1132 | if((RKL_EXPECTED(replacementU16Length64 >= (uint64_t)INT_MAX, 0L) || RKL_EXPECTED(((searchU16Length64 / 2ULL) + (replacementU16Length64 * 2ULL)) >= (uint64_t)INT_MAX, 0L))) { *exception = [NSException exceptionWithName:NSRangeException reason:@"Replacement string length exceeds INT_MAX." userInfo:NULL]; goto exitNow; } 1133 | 1134 | RKLCDelayedAssert((searchU16Length64 < (uint64_t)INT_MAX) && (replacementU16Length64 < (uint64_t)INT_MAX) && (((searchU16Length64 / 2ULL) + (replacementU16Length64 * 2ULL)) < (uint64_t)INT_MAX), exception, exitNow); 1135 | 1136 | // Zero order approximation of the buffer sizes for holding the replaced string or split strings and split strings pointer offsets. As UTF16 code units. 1137 | tempUniCharBufferU16Capacity = (int32_t)(16UL + (searchU16Length + (searchU16Length / 2UL)) + (replacementU16Length * 2UL)); 1138 | RKLCDelayedAssert((tempUniCharBufferU16Capacity < INT_MAX) && (tempUniCharBufferU16Capacity > 0), exception, exitNow); 1139 | 1140 | // Buffer sizes converted from native units to bytes. 1141 | size_t stackSize = 0UL, replacementSize = ((size_t)replacementU16Length * sizeof(UniChar)), tempUniCharBufferSize = ((size_t)tempUniCharBufferU16Capacity * sizeof(UniChar)); 1142 | 1143 | // For the various buffers we require, we first try to allocate from the stack if we're not over the RKL_STACK_LIMIT. If we are, switch to using the heap for the buffer. 1144 | if((stackSize + tempUniCharBufferSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)alloca(tempUniCharBufferSize)) == NULL, 0L)) { goto exitNow; } stackSize += tempUniCharBufferSize; } 1145 | else { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], tempUniCharBufferSize, 0UL)) == NULL, 0L)) { goto exitNow; } } 1146 | 1147 | // Try to get the pointer to the replacement strings UTF16 data. If we can't, allocate some buffer space, then covert to UTF16. 1148 | if((replacementUniChar = CFStringGetCharactersPtr((CFStringRef)replacementString)) == NULL) { 1149 | UniChar *uniCharBuffer = NULL; 1150 | if((stackSize + replacementSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)alloca(replacementSize)) == NULL, 0L)) { goto exitNow; } stackSize += replacementSize; } 1151 | else { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[1], replacementSize, 0UL)) == NULL, 0L)) { goto exitNow; } } 1152 | CFStringGetCharacters((CFStringRef)replacementString, CFMakeRange(0L, replacementU16Length), uniCharBuffer); // Convert to a UTF16 string. 1153 | replacementUniChar = uniCharBuffer; 1154 | } 1155 | 1156 | resultU16Length = rkl_replaceAll(cacheSlot, replacementUniChar, (int32_t)replacementU16Length, tempUniCharBuffer, tempUniCharBufferU16Capacity, &replacedCount, &needU16Capacity, exception, status); 1157 | RKLCDelayedAssert((resultU16Length <= tempUniCharBufferU16Capacity) && (needU16Capacity >= resultU16Length) && (needU16Capacity >= 0), exception, exitNow); 1158 | if(RKL_EXPECTED(needU16Capacity >= INT_MAX, 0L)) { *exception = [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Replaced string length exceeds INT_MAX." userInfo:NULL]; goto exitNow; } 1159 | 1160 | if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { // Our buffer guess(es) were too small. Resize the buffers and try again. 1161 | tempUniCharBufferSize = ((size_t)(tempUniCharBufferU16Capacity = needU16Capacity + 4) * sizeof(UniChar)); // Use needU16Capacity. Bug 2890810. 1162 | if((stackSize + tempUniCharBufferSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)alloca(tempUniCharBufferSize)) == NULL, 0L)) { goto exitNow; } stackSize += tempUniCharBufferSize; } // Warning about stackSize can be safely ignored. 1163 | else { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], tempUniCharBufferSize, 0UL)) == NULL, 0L)) { goto exitNow; } } 1164 | 1165 | *status = U_ZERO_ERROR; // Make sure the status var is cleared and try again. 1166 | resultU16Length = rkl_replaceAll(cacheSlot, replacementUniChar, (int32_t)replacementU16Length, tempUniCharBuffer, tempUniCharBufferU16Capacity, &replacedCount, &needU16Capacity, exception, status); 1167 | RKLCDelayedAssert((resultU16Length <= tempUniCharBufferU16Capacity) && (needU16Capacity >= resultU16Length) && (needU16Capacity >= 0), exception, exitNow); 1168 | } 1169 | 1170 | // If status != U_ZERO_ERROR, consider it an error, even though status < U_ZERO_ERROR is a 'warning' in ICU nomenclature. 1171 | // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 1172 | if(RKL_EXPECTED(*status != U_ZERO_ERROR, 0L)) { goto exitNow; } // Something went wrong. 1173 | 1174 | if(resultU16Length == 0) { resultObject = @""; } // Optimize the case where the replaced text length == 0 with a @"" string. 1175 | else if(((NSUInteger)resultU16Length == searchU16Length) && (replacedCount == 0UL)) { // Optimize the case where the replacement == original by creating a copy. Very fast if self is immutable. 1176 | if(replaceMutable == 0UL) { resultObject = rkl_CFAutorelease(CFStringCreateCopy(NULL, (CFStringRef)searchString)); } // .. but only if this is not replacing a mutable self. Warning about potential leak can be safely ignored. 1177 | } else { resultObject = rkl_CFAutorelease(CFStringCreateWithCharacters(NULL, tempUniCharBuffer, (CFIndex)resultU16Length)); } // otherwise, create a new string. Warning about potential leak can be safely ignored. 1178 | 1179 | // If replaceMutable == 1UL, we don't do the replacement here. We wait until after we return and unlock the cache lock. 1180 | // This is because we may be trying to mutate an immutable string object. 1181 | if((replacedCount > 0UL) && (replaceMutable == 1UL)) { // We're working on a mutable string and there were successfull matches with replaced text, so there's work to do. 1182 | rkl_clearBuffer((cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer, 0UL); 1183 | rkl_clearCacheSlotSetTo(cacheSlot); // Flush any cached information about this string since it will mutate. 1184 | } 1185 | 1186 | exitNow: 1187 | if(scratchBuffer[0] != NULL) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } 1188 | if(scratchBuffer[1] != NULL) { scratchBuffer[1] = rkl_free(&scratchBuffer[1]); } 1189 | if(replacedCountPtr != NULL) { *replacedCountPtr = replacedCount; } 1190 | return(resultObject); 1191 | } // The two warnings about potential leaks can be safely ignored. 1192 | 1193 | // IMPORTANT! Should only be called from rkl_replaceString(). 1194 | // ---------- 1195 | // Modified version of the ICU libraries uregex_replaceAll() that keeps count of the number of replacements made. 1196 | 1197 | static int32_t rkl_replaceAll(RKLCacheSlot *cacheSlot, const UniChar *replacementUniChar, int32_t replacementU16Length, UniChar *replacedUniChar, int32_t replacedU16Capacity, NSUInteger *replacedCount, int32_t *needU16Capacity, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) { 1198 | int32_t u16Length = 0, initialReplacedU16Capacity = replacedU16Capacity; 1199 | NSUInteger replaced = 0UL, bufferOverflowed = 0UL; 1200 | RKLCDelayedAssert((cacheSlot != NULL) && (replacementUniChar != NULL) && (replacedUniChar != NULL) && (replacedCount != NULL) && (needU16Capacity != NULL) && (status != NULL) && (replacementU16Length >= 0) && (replacedU16Capacity >= 0), exception, exitNow); 1201 | 1202 | cacheSlot->lastFindRange = cacheSlot->lastMatchRange = NSNotFoundRange; // Clear the cached find information for this regex so a subsequent find works correctly. 1203 | RKL_ICU_FUNCTION_APPEND(uregex_reset)(cacheSlot->icu_regex, 0, status); 1204 | 1205 | // Work around for ICU uregex_reset() bug, see http://bugs.icu-project.org/trac/ticket/6545 1206 | // http://sourceforge.net/tracker/index.php?func=detail&aid=2105213&group_id=204582&atid=990188 1207 | if(RKL_EXPECTED(cacheSlot->setToRange.length == 0L, 0L) && (*status == U_INDEX_OUTOFBOUNDS_ERROR)) { *status = U_ZERO_ERROR; } 1208 | 1209 | // This loop originally came from ICU source/i18n/uregex.cpp, uregex_replaceAll. 1210 | // There is a bug in that code which causes the size of the buffer required for the replaced text to not be calculated correctly. 1211 | // This contains a work around using the variable bufferOverflowed. 1212 | // ICU bug: http://bugs.icu-project.org/trac/ticket/6656 1213 | // http://sourceforge.net/tracker/index.php?func=detail&aid=2408447&group_id=204582&atid=990188 1214 | while(RKL_ICU_FUNCTION_APPEND(uregex_findNext)(cacheSlot->icu_regex, status)) { 1215 | replaced++; 1216 | u16Length += RKL_ICU_FUNCTION_APPEND(uregex_appendReplacement)(cacheSlot->icu_regex, replacementUniChar, replacementU16Length, &replacedUniChar, &replacedU16Capacity, status); 1217 | if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { bufferOverflowed = 1UL; *status = U_ZERO_ERROR; } 1218 | } 1219 | if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { bufferOverflowed = 1UL; *status = U_ZERO_ERROR; } 1220 | u16Length += RKL_ICU_FUNCTION_APPEND(uregex_appendTail)(cacheSlot->icu_regex, &replacedUniChar, &replacedU16Capacity, status); 1221 | 1222 | // Check for status <= U_ZERO_ERROR (a 'warning' in ICU nomenclature) rather than just status == U_ZERO_ERROR. 1223 | // Under just the right circumstances, status might be equal to U_STRING_NOT_TERMINATED_WARNING. When this occured, 1224 | // rkl_replaceString would never get the U_BUFFER_OVERFLOW_ERROR status, and thus never grow the buffer to the size needed. 1225 | // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 1226 | if(RKL_EXPECTED(*status <= U_ZERO_ERROR, 1L) && RKL_EXPECTED(bufferOverflowed == 1UL, 0L)) { *status = U_BUFFER_OVERFLOW_ERROR; } 1227 | 1228 | #ifndef NS_BLOCK_ASSERTIONS 1229 | exitNow: 1230 | #endif 1231 | if(replacedCount != NULL) { *replacedCount = replaced; } 1232 | if(needU16Capacity != NULL) { *needU16Capacity = u16Length; } // Use needU16Capacity to return the number of characters that are needed for the completely replaced string. Bug 2890810. 1233 | return(initialReplacedU16Capacity - replacedU16Capacity); // Return the number of characters of replacedUniChar that were used. 1234 | } 1235 | 1236 | static NSUInteger rkl_isRegexValid(id self, SEL _cmd, NSString *regex, RKLRegexOptions options, NSInteger *captureCountPtr, NSError **error) { 1237 | volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; 1238 | 1239 | RKLCacheSlot *cacheSlot = NULL; 1240 | NSUInteger gotCacheSlot = 0UL; 1241 | NSInteger captureCount = -1L; 1242 | id exception = NULL; 1243 | 1244 | if((error != NULL) && (*error != NULL)) { *error = NULL; } 1245 | if(regex == NULL) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The regular expression argument is NULL."); } 1246 | 1247 | OSSpinLockLock(&cacheSpinLock); 1248 | cacheSpinLockStatus |= RKLLockedCacheSpinLock; 1249 | rkl_dtrace_incrementEventID(); 1250 | if((cacheSlot = rkl_getCachedRegex(regex, options, error, &exception)) != NULL) { gotCacheSlot = 1UL; captureCount = cacheSlot->captureCount; } 1251 | cacheSlot = NULL; 1252 | OSSpinLockUnlock(&cacheSpinLock); 1253 | cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. 1254 | 1255 | if(captureCountPtr != NULL) { *captureCountPtr = captureCount; } 1256 | if(RKL_EXPECTED(exception != NULL, 0L)) { rkl_handleDelayedAssert(self, _cmd, exception); } 1257 | return(gotCacheSlot); 1258 | } 1259 | 1260 | static void rkl_clearStringCache(void) { 1261 | NSCParameterAssert(cacheSpinLock != (OSSpinLock)0); 1262 | lastCacheSlot = NULL; 1263 | NSUInteger x = 0UL; 1264 | for(x = 0UL; x < (NSUInteger)(RKL_SCRATCH_BUFFERS); x++) { if(scratchBuffer[x] != NULL) { scratchBuffer[x] = rkl_free(&scratchBuffer[x]); } } 1265 | for(x = 0UL; x < (NSUInteger)(RKL_CACHE_SIZE); x++) { rkl_clearCacheSlotRegex(&rkl_cacheSlots[x]); } 1266 | rkl_clearBuffer(&fixedBuffer, 0UL); 1267 | rkl_clearBuffer(&dynamicBuffer, 1UL); 1268 | } 1269 | 1270 | static void rkl_clearBuffer(RKLBuffer *buffer, NSUInteger freeDynamicBuffer) { 1271 | if(buffer == NULL) { return; } 1272 | if((freeDynamicBuffer == 1UL) && (buffer->uniChar != NULL) && (buffer == &dynamicBuffer)) { RKL_STRONG_REF void *p = (RKL_STRONG_REF void *)dynamicBuffer.uniChar; dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)rkl_free(&p); } 1273 | if(buffer->string != NULL) { CFRelease((CFTypeRef)buffer->string); buffer->string = NULL; } 1274 | buffer->length = 0L; 1275 | buffer->hash = 0UL; 1276 | } 1277 | 1278 | static void rkl_clearCacheSlotRegex(RKLCacheSlot *cacheSlot) { 1279 | if(cacheSlot == NULL) { return; } 1280 | if(cacheSlot->setToString != NULL) { rkl_clearCacheSlotSetTo(cacheSlot); } 1281 | if(cacheSlot->icu_regex != NULL) { RKL_ICU_FUNCTION_APPEND(uregex_close)(cacheSlot->icu_regex); cacheSlot->icu_regex = NULL; cacheSlot->captureCount = -1L; } 1282 | if(cacheSlot->regexString != NULL) { CFRelease((CFTypeRef)cacheSlot->regexString); cacheSlot->regexString = NULL; cacheSlot->options = 0U; } 1283 | } 1284 | 1285 | static void rkl_clearCacheSlotSetTo(RKLCacheSlot *cacheSlot) { 1286 | if(cacheSlot == NULL) { return; } 1287 | if(cacheSlot->icu_regex != NULL) { int32_t status = 0; RKL_ICU_FUNCTION_APPEND(uregex_setText)(cacheSlot->icu_regex, &emptyUniCharString[0], 0, &status); } 1288 | if(cacheSlot->setToString != NULL) { CFRelease((CFTypeRef)cacheSlot->setToString); cacheSlot->setToString = NULL; } 1289 | cacheSlot->lastFindRange = cacheSlot->lastMatchRange = cacheSlot->setToRange = NSNotFoundRange; 1290 | cacheSlot->setToIsImmutable = cacheSlot->setToNeedsConversion = 0U; 1291 | cacheSlot->setToUniChar = NULL; 1292 | cacheSlot->setToHash = 0UL; 1293 | cacheSlot->setToLength = 0L; 1294 | } 1295 | 1296 | // Helps to keep things tidy. 1297 | #define addKeyAndObject(objs, keys, i, k, o) ({id _o=(o), _k=(k); if((_o != NULL) && (_k != NULL)) { objs[i] = _o; keys[i] = _k; i++; } }) 1298 | 1299 | static NSDictionary *rkl_userInfoDictionary(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status, ...) { 1300 | va_list varArgsList; 1301 | va_start(varArgsList, status); 1302 | if(regexString == NULL) { va_end(varArgsList); return(NULL); } 1303 | 1304 | id objects[64], keys[64]; 1305 | NSUInteger count = 0UL; 1306 | 1307 | NSString *errorNameString = [NSString stringWithUTF8String:RKL_ICU_FUNCTION_APPEND(u_errorName)(status)]; 1308 | 1309 | addKeyAndObject(objects, keys, count, RKLICURegexRegexErrorKey, regexString); 1310 | addKeyAndObject(objects, keys, count, RKLICURegexRegexOptionsErrorKey, [NSNumber numberWithUnsignedInt:options]); 1311 | addKeyAndObject(objects, keys, count, RKLICURegexErrorCodeErrorKey, [NSNumber numberWithInt:status]); 1312 | addKeyAndObject(objects, keys, count, RKLICURegexErrorNameErrorKey, errorNameString); 1313 | 1314 | if((parseError != NULL) && (parseError->line != -1)) { 1315 | NSString *preContextString = [NSString stringWithCharacters:&parseError->preContext[0] length:(NSUInteger)RKL_ICU_FUNCTION_APPEND(u_strlen)(&parseError->preContext[0])]; 1316 | NSString *postContextString = [NSString stringWithCharacters:&parseError->postContext[0] length:(NSUInteger)RKL_ICU_FUNCTION_APPEND(u_strlen)(&parseError->postContext[0])]; 1317 | 1318 | addKeyAndObject(objects, keys, count, RKLICURegexLineErrorKey, [NSNumber numberWithInt:parseError->line]); 1319 | addKeyAndObject(objects, keys, count, RKLICURegexOffsetErrorKey, [NSNumber numberWithInt:parseError->offset]); 1320 | addKeyAndObject(objects, keys, count, RKLICURegexPreContextErrorKey, preContextString); 1321 | addKeyAndObject(objects, keys, count, RKLICURegexPostContextErrorKey, postContextString); 1322 | addKeyAndObject(objects, keys, count, @"NSLocalizedFailureReason", ([NSString stringWithFormat:@"The error %@ occurred at line %d, column %d: %@<>%@", errorNameString, parseError->line, parseError->offset, preContextString, postContextString])); 1323 | } else { 1324 | addKeyAndObject(objects, keys, count, @"NSLocalizedFailureReason", ([NSString stringWithFormat:@"The error %@ occurred.", errorNameString])); 1325 | } 1326 | 1327 | while(count < 62UL) { id obj = va_arg(varArgsList, id), key = va_arg(varArgsList, id); if((obj != NULL) && (key != NULL)) { addKeyAndObject(objects, keys, count, key, obj); } else { break; } } 1328 | va_end(varArgsList); 1329 | 1330 | return([NSDictionary dictionaryWithObjects:&objects[0] forKeys:&keys[0] count:count]); 1331 | } 1332 | 1333 | static NSError *rkl_NSErrorForRegex(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) { 1334 | return([NSError errorWithDomain:RKLICURegexErrorDomain code:(NSInteger)status userInfo:rkl_userInfoDictionary(regexString, options, parseError, status, @"There was an error compiling the regular expression.", @"NSLocalizedDescription", NULL)]); 1335 | } 1336 | 1337 | static NSException *rkl_NSExceptionForRegex(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) { 1338 | return([NSException exceptionWithName:RKLICURegexException reason:[NSString stringWithFormat:@"ICU regular expression error #%d, %s.", status, RKL_ICU_FUNCTION_APPEND(u_errorName)(status)] userInfo:rkl_userInfoDictionary(regexString, options, parseError, status, NULL)]); 1339 | } 1340 | 1341 | static NSDictionary *rkl_makeAssertDictionary(const char *function, const char *file, int line, NSString *format, ...) { 1342 | va_list varArgsList; 1343 | va_start(varArgsList, format); 1344 | NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease]; 1345 | va_end(varArgsList); 1346 | NSString *functionString = [NSString stringWithUTF8String:function], *fileString = [NSString stringWithUTF8String:file]; 1347 | return([NSDictionary dictionaryWithObjectsAndKeys:formatString, @"description", functionString, @"function", fileString, @"file", [NSNumber numberWithInt:line], @"line", NSInternalInconsistencyException, @"exceptionName", NULL]); 1348 | } 1349 | 1350 | static NSString *rkl_stringFromClassAndMethod(id object, SEL selector, NSString *format, ...) { 1351 | va_list varArgsList; 1352 | va_start(varArgsList, format); 1353 | NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease]; 1354 | va_end(varArgsList); 1355 | Class objectsClass = [object class]; 1356 | return([NSString stringWithFormat:@"*** %c[%@ %@]: %@", (object == objectsClass) ? '+' : '-', NSStringFromClass(objectsClass), NSStringFromSelector(selector), formatString]); 1357 | } 1358 | 1359 | #pragma mark - 1360 | #pragma mark Objective-C Public Interface 1361 | #pragma mark - 1362 | 1363 | @implementation NSString (RegexKitLiteAdditions) 1364 | 1365 | #pragma mark +clearStringCache 1366 | 1367 | + (void)RKL_METHOD_PREPEND(clearStringCache) 1368 | { 1369 | volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; 1370 | OSSpinLockLock(&cacheSpinLock); 1371 | cacheSpinLockStatus |= RKLLockedCacheSpinLock; 1372 | rkl_clearStringCache(); 1373 | OSSpinLockUnlock(&cacheSpinLock); 1374 | cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. 1375 | } 1376 | 1377 | #pragma mark +captureCountForRegex: 1378 | 1379 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex 1380 | { 1381 | NSInteger captureCount = -1L; 1382 | rkl_isRegexValid(self, _cmd, regex, RKLNoOptions, &captureCount, NULL); 1383 | return(captureCount); 1384 | } 1385 | 1386 | + (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error 1387 | { 1388 | NSInteger captureCount = -1L; 1389 | rkl_isRegexValid(self, _cmd, regex, options, &captureCount, error); 1390 | return(captureCount); 1391 | } 1392 | 1393 | #pragma mark -captureCount: 1394 | 1395 | - (NSInteger)RKL_METHOD_PREPEND(captureCount) 1396 | { 1397 | NSInteger captureCount = -1L; 1398 | rkl_isRegexValid(self, _cmd, self, RKLNoOptions, &captureCount, NULL); 1399 | return(captureCount); 1400 | } 1401 | 1402 | - (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error 1403 | { 1404 | NSInteger captureCount = -1L; 1405 | rkl_isRegexValid(self, _cmd, self, options, &captureCount, error); 1406 | return(captureCount); 1407 | } 1408 | 1409 | #pragma mark -componentsSeparatedByRegex: 1410 | 1411 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex 1412 | { 1413 | NSRange range = NSMaxiumRange; 1414 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); 1415 | } 1416 | 1417 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range 1418 | { 1419 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); 1420 | } 1421 | 1422 | - (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error 1423 | { 1424 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, options, 0L, self, &range, NULL, error, NULL)); 1425 | } 1426 | 1427 | #pragma mark -isMatchedByRegex: 1428 | 1429 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex 1430 | { 1431 | NSRange result = NSNotFoundRange, range = NSMaxiumRange; 1432 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); 1433 | return((result.location == (NSUInteger)NSNotFound) ? NO : YES); 1434 | } 1435 | 1436 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range 1437 | { 1438 | NSRange result = NSNotFoundRange; 1439 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); 1440 | return((result.location == (NSUInteger)NSNotFound) ? NO : YES); 1441 | } 1442 | 1443 | - (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error 1444 | { 1445 | NSRange result = NSNotFoundRange; 1446 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, 0L, self, &range, NULL, error, &result); 1447 | return((result.location == (NSUInteger)NSNotFound) ? NO : YES); 1448 | } 1449 | 1450 | #pragma mark -isRegexValid 1451 | 1452 | - (BOOL)RKL_METHOD_PREPEND(isRegexValid) 1453 | { 1454 | return(rkl_isRegexValid(self, _cmd, self, RKLNoOptions, NULL, NULL) == 1UL ? YES : NO); 1455 | } 1456 | 1457 | - (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error 1458 | { 1459 | return(rkl_isRegexValid(self, _cmd, self, options, NULL, error) == 1UL ? YES : NO); 1460 | } 1461 | 1462 | #pragma mark -flushCachedRegexData 1463 | 1464 | - (void)RKL_METHOD_PREPEND(flushCachedRegexData) 1465 | { 1466 | volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; 1467 | 1468 | CFIndex selfLength = CFStringGetLength((CFStringRef)self); 1469 | CFHashCode selfHash = CFHash((CFTypeRef)self); 1470 | 1471 | OSSpinLockLock(&cacheSpinLock); 1472 | cacheSpinLockStatus |= RKLLockedCacheSpinLock; 1473 | rkl_dtrace_incrementEventID(); 1474 | 1475 | NSUInteger slot; 1476 | for(slot = 0UL; slot < (NSUInteger)(RKL_CACHE_SIZE); slot++) { 1477 | RKLCacheSlot *cacheSlot = &rkl_cacheSlots[slot]; 1478 | if((cacheSlot->setToString != NULL) && ( (cacheSlot->setToString == (CFStringRef)self) || ((cacheSlot->setToLength == selfLength) && (cacheSlot->setToHash == selfHash)) ) ) { rkl_clearCacheSlotSetTo(cacheSlot); } 1479 | } 1480 | 1481 | RKLBuffer *buffer = (selfLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer; 1482 | if((buffer->string != NULL) && ((buffer->string == (CFStringRef)self) || ((buffer->length == selfLength) && (buffer->hash == selfHash)))) { rkl_clearBuffer(buffer, 0UL); } 1483 | 1484 | OSSpinLockUnlock(&cacheSpinLock); 1485 | cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. 1486 | } 1487 | 1488 | #pragma mark -rangeOfRegex: 1489 | 1490 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex 1491 | { 1492 | NSRange result = NSNotFoundRange, range = NSMaxiumRange; 1493 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); 1494 | return(result); 1495 | } 1496 | 1497 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture 1498 | { 1499 | NSRange result = NSNotFoundRange, range = NSMaxiumRange; 1500 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, capture, self, &range, NULL, NULL, &result); 1501 | return(result); 1502 | } 1503 | 1504 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range 1505 | { 1506 | NSRange result = NSNotFoundRange; 1507 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); 1508 | return(result); 1509 | } 1510 | 1511 | - (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error 1512 | { 1513 | NSRange result = NSNotFoundRange; 1514 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, capture, self, &range, NULL, error, &result); 1515 | return(result); 1516 | } 1517 | 1518 | #pragma mark -stringByMatching: 1519 | 1520 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex 1521 | { 1522 | NSRange matchedRange = NSNotFoundRange, range = NSMaxiumRange; 1523 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &matchedRange); 1524 | return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); 1525 | } // Warning about potential leak can be safely ignored. 1526 | 1527 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture 1528 | { 1529 | NSRange matchedRange = NSNotFoundRange, range = NSMaxiumRange; 1530 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, capture, self, &range, NULL, NULL, &matchedRange); 1531 | return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); 1532 | } // Warning about potential leak can be safely ignored. 1533 | 1534 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range 1535 | { 1536 | NSRange matchedRange = NSNotFoundRange; 1537 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &matchedRange); 1538 | return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); 1539 | } // Warning about potential leak can be safely ignored. 1540 | 1541 | - (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error 1542 | { 1543 | NSRange matchedRange = NSNotFoundRange; 1544 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, capture, self, &range, NULL, error, &matchedRange); 1545 | return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); 1546 | } // Warning about potential leak can be safely ignored. 1547 | 1548 | #pragma mark -stringByReplacingOccurrencesOfRegex: 1549 | 1550 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement 1551 | { 1552 | NSRange searchRange = NSMaxiumRange; 1553 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, NULL)); 1554 | } 1555 | 1556 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange 1557 | { 1558 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, NULL)); 1559 | } 1560 | 1561 | - (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error 1562 | { 1563 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, options, 0L, self, &searchRange, replacement, error, NULL)); 1564 | } 1565 | 1566 | #pragma mark -componentsMatchedByRegex: 1567 | 1568 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex 1569 | { 1570 | NSRange searchRange = NSMaxiumRange; 1571 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); 1572 | } 1573 | 1574 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture 1575 | { 1576 | NSRange searchRange = NSMaxiumRange; 1577 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, capture, self, &searchRange, NULL, NULL, NULL)); 1578 | } 1579 | 1580 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range 1581 | { 1582 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); 1583 | } 1584 | 1585 | - (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error 1586 | { 1587 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, options, capture, self, &range, NULL, error, NULL)); 1588 | } 1589 | 1590 | #pragma mark -captureComponentsMatchedByRegex: 1591 | 1592 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex 1593 | { 1594 | NSRange searchRange = NSMaxiumRange; 1595 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); 1596 | } 1597 | 1598 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range 1599 | { 1600 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); 1601 | } 1602 | 1603 | - (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error 1604 | { 1605 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, options, 0L, self, &range, NULL, error, NULL)); 1606 | } 1607 | 1608 | #pragma mark -arrayOfCaptureComponentsMatchedByRegex: 1609 | 1610 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex 1611 | { 1612 | NSRange searchRange = NSMaxiumRange; 1613 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); 1614 | } 1615 | 1616 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range 1617 | { 1618 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); 1619 | } 1620 | 1621 | - (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error 1622 | { 1623 | return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, options, 0L, self, &range, NULL, error, NULL)); 1624 | } 1625 | 1626 | @end 1627 | 1628 | 1629 | @implementation NSMutableString (RegexKitLiteAdditions) 1630 | 1631 | #pragma mark -replaceOccurrencesOfRegex: 1632 | 1633 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement 1634 | { 1635 | NSRange searchRange = NSMaxiumRange; 1636 | NSUInteger replacedCount = 0UL; 1637 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, (void **)((void *)&replacedCount)); 1638 | return(replacedCount); 1639 | } 1640 | 1641 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange 1642 | { 1643 | NSUInteger replacedCount = 0UL; 1644 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, (void **)((void *)&replacedCount)); 1645 | return(replacedCount); 1646 | } 1647 | 1648 | - (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error 1649 | { 1650 | NSUInteger replacedCount = 0UL; 1651 | rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, options, 0L, self, &searchRange, replacement, error, (void **)((void *)&replacedCount)); 1652 | return(replacedCount); 1653 | } 1654 | 1655 | @end 1656 | --------------------------------------------------------------------------------