Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved helper functions inspired by ruby.

  • Loading branch information...
commit e6c0e648a5a11f7035a2a568bd000ead22207e54 1 parent 3dae527
@psychs authored
View
307 framework/CocoaOniguruma.xcodeproj/project.pbxproj
@@ -30,12 +30,34 @@
7807AC500E2FBB8600A5AB6A /* regversion.c in Sources */ = {isa = PBXBuildFile; fileRef = 7807AC340E2FBB8600A5AB6A /* regversion.c */; };
7807AC510E2FBB8600A5AB6A /* st.c in Sources */ = {isa = PBXBuildFile; fileRef = 7807AC350E2FBB8600A5AB6A /* st.c */; };
7807AC520E2FBB8600A5AB6A /* st.h in Headers */ = {isa = PBXBuildFile; fileRef = 7807AC360E2FBB8600A5AB6A /* st.h */; };
- 78B1D1AB0E2FBEA100C857D5 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78B1D1AA0E2FBEA100C857D5 /* Cocoa.framework */; };
+ 78C5E1CD0E39CE5F00F62F5D /* OnigRegexpTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 78C5E1B70E39CDEE00F62F5D /* OnigRegexpTest.m */; };
+ 78C5E21F0E39CF7300F62F5D /* CocoaOniguruma.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* CocoaOniguruma.framework */; };
+ 78C5E2310E39CFEA00F62F5D /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C5E2300E39CFEA00F62F5D /* SenTestingKit.framework */; };
+ 78C5E26C0E39D0BD00F62F5D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C5E26B0E39D0BD00F62F5D /* Foundation.framework */; };
+ 78C5E3B10E39E38C00F62F5D /* CocoaOniguruma.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* CocoaOniguruma.framework */; };
+ 78C5E3D00E39E42000F62F5D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 78C5E3C00E39E3D900F62F5D /* main.m */; };
+ 78C5E3EC0E39E4B800F62F5D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C5E26B0E39D0BD00F62F5D /* Foundation.framework */; };
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ 78C5E1F70E39CF1A00F62F5D /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
+ remoteInfo = CocoaOniguruma;
+ };
+ 78C5E3E50E39E4A100F62F5D /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
+ remoteInfo = CocoaOniguruma;
+ };
+/* End PBXContainerItemProxy section */
+
/* Begin PBXFileReference section */
- 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* CocoaOniguruma_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaOniguruma_Prefix.pch; sourceTree = "<group>"; };
7807AC1A0E2FBB8600A5AB6A /* OnigRegexp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnigRegexp.h; sourceTree = "<group>"; };
@@ -61,17 +83,42 @@
7807AC340E2FBB8600A5AB6A /* regversion.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = regversion.c; sourceTree = "<group>"; };
7807AC350E2FBB8600A5AB6A /* st.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = st.c; sourceTree = "<group>"; };
7807AC360E2FBB8600A5AB6A /* st.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = st.h; sourceTree = "<group>"; };
- 78B1D1AA0E2FBEA100C857D5 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
+ 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTest.octest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 78C5E1B60E39CDEE00F62F5D /* OnigRegexpTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OnigRegexpTest.h; path = tests/OnigRegexpTest.h; sourceTree = "<group>"; };
+ 78C5E1B70E39CDEE00F62F5D /* OnigRegexpTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OnigRegexpTest.m; path = tests/OnigRegexpTest.m; sourceTree = "<group>"; };
+ 78C5E1E70E39CEBD00F62F5D /* UnitTest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "UnitTest-Info.plist"; sourceTree = "<group>"; };
+ 78C5E2300E39CFEA00F62F5D /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = /Developer/Library/Frameworks/SenTestingKit.framework; sourceTree = "<absolute>"; };
+ 78C5E26B0E39D0BD00F62F5D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 78C5E3A90E39E37F00F62F5D /* TestCommand */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestCommand; sourceTree = BUILT_PRODUCTS_DIR; };
+ 78C5E3C00E39E3D900F62F5D /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = testcommand/main.m; sourceTree = "<group>"; };
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8DC2EF5B0486A6940098B216 /* CocoaOniguruma.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CocoaOniguruma.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
+ 78C5E1AE0E39CDCE00F62F5D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78C5E21F0E39CF7300F62F5D /* CocoaOniguruma.framework in Frameworks */,
+ 78C5E2310E39CFEA00F62F5D /* SenTestingKit.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 78C5E3A70E39E37F00F62F5D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78C5E3EC0E39E4B800F62F5D /* Foundation.framework in Frameworks */,
+ 78C5E3B10E39E38C00F62F5D /* CocoaOniguruma.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
8DC2EF560486A6940098B216 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 78B1D1AB0E2FBEA100C857D5 /* Cocoa.framework in Frameworks */,
+ 78C5E26C0E39D0BD00F62F5D /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -82,6 +129,8 @@
isa = PBXGroup;
children = (
8DC2EF5B0486A6940098B216 /* CocoaOniguruma.framework */,
+ 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */,
+ 78C5E3A90E39E37F00F62F5D /* TestCommand */,
);
name = Products;
sourceTree = "<group>";
@@ -92,19 +141,19 @@
08FB77AEFE84172EC02AAC07 /* Classes */,
32C88DFF0371C24200C91783 /* Other Sources */,
089C1665FE841158C02AAC07 /* Resources */,
- 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,
+ 0867D69AFE84028FC02AAC07 /* Frameworks */,
034768DFFF38A50411DB9C8B /* Products */,
);
name = CocoaOniguruma;
sourceTree = "<group>";
};
- 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {
+ 0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
- 0867D69BFE84028FC02AAC07 /* Foundation.framework */,
- 78B1D1AA0E2FBEA100C857D5 /* Cocoa.framework */,
+ 78C5E26B0E39D0BD00F62F5D /* Foundation.framework */,
+ 78C5E2300E39CFEA00F62F5D /* SenTestingKit.framework */,
);
- name = "External Frameworks and Libraries";
+ name = Frameworks;
sourceTree = "<group>";
};
089C1665FE841158C02AAC07 /* Resources */ = {
@@ -112,6 +161,7 @@
children = (
8DC2EF5A0486A6940098B216 /* Info.plist */,
089C1666FE841158C02AAC07 /* InfoPlist.strings */,
+ 78C5E1E70E39CEBD00F62F5D /* UnitTest-Info.plist */,
);
name = Resources;
sourceTree = "<group>";
@@ -120,6 +170,8 @@
isa = PBXGroup;
children = (
7807AC190E2FBB8600A5AB6A /* core */,
+ 78C5E1BA0E39CDFA00F62F5D /* tests */,
+ 78C5E3DD0E39E45200F62F5D /* testcommand */,
);
name = Classes;
sourceTree = "<group>";
@@ -178,6 +230,23 @@
path = enc;
sourceTree = "<group>";
};
+ 78C5E1BA0E39CDFA00F62F5D /* tests */ = {
+ isa = PBXGroup;
+ children = (
+ 78C5E1B60E39CDEE00F62F5D /* OnigRegexpTest.h */,
+ 78C5E1B70E39CDEE00F62F5D /* OnigRegexpTest.m */,
+ );
+ name = tests;
+ sourceTree = "<group>";
+ };
+ 78C5E3DD0E39E45200F62F5D /* testcommand */ = {
+ isa = PBXGroup;
+ children = (
+ 78C5E3C00E39E3D900F62F5D /* main.m */,
+ );
+ name = testcommand;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@@ -199,6 +268,42 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
+ 78C5E1B00E39CDCE00F62F5D /* UnitTest */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 78C5E1B50E39CDCF00F62F5D /* Build configuration list for PBXNativeTarget "UnitTest" */;
+ buildPhases = (
+ 78C5E1AC0E39CDCE00F62F5D /* Resources */,
+ 78C5E1AD0E39CDCE00F62F5D /* Sources */,
+ 78C5E1AE0E39CDCE00F62F5D /* Frameworks */,
+ 78C5E1AF0E39CDCE00F62F5D /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 78C5E1F80E39CF1A00F62F5D /* PBXTargetDependency */,
+ );
+ name = UnitTest;
+ productName = UnitTest;
+ productReference = 78C5E1B10E39CDCE00F62F5D /* UnitTest.octest */;
+ productType = "com.apple.product-type.bundle";
+ };
+ 78C5E3A80E39E37F00F62F5D /* TestCommand */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 78C5E3BC0E39E39300F62F5D /* Build configuration list for PBXNativeTarget "TestCommand" */;
+ buildPhases = (
+ 78C5E3A60E39E37F00F62F5D /* Sources */,
+ 78C5E3A70E39E37F00F62F5D /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 78C5E3E60E39E4A100F62F5D /* PBXTargetDependency */,
+ );
+ name = TestCommand;
+ productName = TestCommand;
+ productReference = 78C5E3A90E39E37F00F62F5D /* TestCommand */;
+ productType = "com.apple.product-type.tool";
+ };
8DC2EF4F0486A6940098B216 /* CocoaOniguruma */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "CocoaOniguruma" */;
@@ -232,11 +337,20 @@
projectRoot = "";
targets = (
8DC2EF4F0486A6940098B216 /* CocoaOniguruma */,
+ 78C5E1B00E39CDCE00F62F5D /* UnitTest */,
+ 78C5E3A80E39E37F00F62F5D /* TestCommand */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
+ 78C5E1AC0E39CDCE00F62F5D /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
8DC2EF520486A6940098B216 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -247,7 +361,39 @@
};
/* End PBXResourcesBuildPhase section */
+/* Begin PBXShellScriptBuildPhase section */
+ 78C5E1AF0E39CDCE00F62F5D /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
+ 78C5E1AD0E39CDCE00F62F5D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78C5E1CD0E39CE5F00F62F5D /* OnigRegexpTest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 78C5E3A60E39E37F00F62F5D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 78C5E3D00E39E42000F62F5D /* main.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
8DC2EF540486A6940098B216 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -272,6 +418,19 @@
};
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ 78C5E1F80E39CF1A00F62F5D /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 8DC2EF4F0486A6940098B216 /* CocoaOniguruma */;
+ targetProxy = 78C5E1F70E39CF1A00F62F5D /* PBXContainerItemProxy */;
+ };
+ 78C5E3E60E39E4A100F62F5D /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 8DC2EF4F0486A6940098B216 /* CocoaOniguruma */;
+ targetProxy = 78C5E3E50E39E4A100F62F5D /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin PBXVariantGroup section */
089C1666FE841158C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
@@ -328,7 +487,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+ SDKROOT = "";
};
name = Debug;
};
@@ -344,7 +503,115 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "";
PREBINDING = NO;
- SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
+ SDKROOT = "";
+ };
+ name = Release;
+ };
+ 78C5E1B30E39CDCE00F62F5D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
+ /Developer/Library/Frameworks,
+ "\"$(SRCROOT)/build/Debug\"",
+ );
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
+ INFOPLIST_FILE = "UnitTest-Info.plist";
+ INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Cocoa,
+ "-framework",
+ SenTestingKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = UnitTest;
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Debug;
+ };
+ 78C5E1B40E39CDCE00F62F5D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
+ /Developer/Library/Frameworks,
+ "\"$(SRCROOT)/build/Debug\"",
+ );
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h";
+ INFOPLIST_FILE = "UnitTest-Info.plist";
+ INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles";
+ OTHER_LDFLAGS = (
+ "-framework",
+ Cocoa,
+ "-framework",
+ SenTestingKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = UnitTest;
+ WRAPPER_EXTENSION = octest;
+ ZERO_LINK = NO;
+ };
+ name = Release;
+ };
+ 78C5E3AB0E39E37F00F62F5D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+ INSTALL_PATH = /usr/local/bin;
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = TestCommand;
+ };
+ name = Debug;
+ };
+ 78C5E3AC0E39E37F00F62F5D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+ INSTALL_PATH = /usr/local/bin;
+ OTHER_LDFLAGS = (
+ "-framework",
+ Foundation,
+ "-framework",
+ AppKit,
+ );
+ PREBINDING = NO;
+ PRODUCT_NAME = TestCommand;
+ ZERO_LINK = NO;
};
name = Release;
};
@@ -369,6 +636,24 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 78C5E1B50E39CDCF00F62F5D /* Build configuration list for PBXNativeTarget "UnitTest" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 78C5E1B30E39CDCE00F62F5D /* Debug */,
+ 78C5E1B40E39CDCE00F62F5D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 78C5E3BC0E39E39300F62F5D /* Build configuration list for PBXNativeTarget "TestCommand" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 78C5E3AB0E39E37F00F62F5D /* Debug */,
+ 78C5E3AC0E39E37F00F62F5D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
View
20 framework/UnitTest-Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>net.limechat.CocoaOnigurumaTest</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
View
24 framework/core/OnigRegexpUtility.h
@@ -11,19 +11,31 @@
@interface NSString (OnigRegexpUtility)
-// expression is OnigRegexp or NSString
+// pattern is OnigRegexp or NSString
-- (NSRange)rangeOfRegexp:(id)expression;
-- (NSArray*)splitByRegexp:(id)expression;
+- (NSRange)rangeOfRegexp:(id)pattern;
+
+// based on ruby's split
+
+- (NSArray*)split;
+- (NSArray*)splitByRegexp:(id)pattern;
+- (NSArray*)splitByRegexp:(id)pattern limit:(int)limit;
+
+// based on ruby's gsub
+
+- (NSString*)replaceByRegexp:(id)pattern with:(NSString*)string;
+- (NSString*)replaceAllByRegexp:(id)pattern with:(NSString*)string;
@end
@interface NSMutableString (OnigRegexpUtility)
-// expression is OnigRegexp or NSString
+// pattern is OnigRegexp or NSString
+
+// based on ruby's gsub
-- (BOOL)replaceByRegexp:(id)expression with:(NSString*)string;
-- (int)replaceAllByRegexp:(id)expression with:(NSString*)string;
+- (NSMutableString*)replaceByRegexp:(id)pattern with:(NSString*)string;
+- (NSMutableString*)replaceAllByRegexp:(id)pattern with:(NSString*)string;
@end
View
203 framework/core/OnigRegexpUtility.m
@@ -4,77 +4,200 @@
#import "OnigRegexpUtility.h"
-@implementation NSString (OnigRegexpUtility)
+@interface NSString (OnigRegexpNSStringUtilityPrivate)
+- (NSArray*)__split:(id)pattern limit:(NSNumber*)limit;
+@end
+
+@implementation NSString (OnigRegexpNSStringUtility)
-- (NSRange)rangeOfRegexp:(id)expression
+- (NSRange)rangeOfRegexp:(id)pattern
{
- if (![expression isKindOfClass:[OnigRegexp class]]) {
- expression = [OnigRegexp compile:(NSString*)expression];
+ if (![pattern isKindOfClass:[OnigRegexp class]]) {
+ pattern = [OnigRegexp compile:(NSString*)pattern];
}
- OnigResult* res = [expression search:self];
+ OnigResult* res = [pattern search:self];
return res ? [res bodyRange] : NSMakeRange(NSNotFound, 0);
}
-- (NSArray*)splitByRegexp:(id)expression
+- (NSArray*)split
+{
+ return [self splitByRegexp:@" "];
+}
+
+- (NSArray*)splitByRegexp:(id)pattern
{
- if (![expression isKindOfClass:[OnigRegexp class]]) {
- expression = [OnigRegexp compile:(NSString*)expression];
+ return [self __split:pattern limit:nil];
+}
+
+- (NSArray*)splitByRegexp:(id)pattern limit:(int)limit
+{
+ return [self __split:pattern limit:[NSNumber numberWithInt:limit]];
+}
+
+//
+// This implementation is based on ruby 1.8.
+//
+
+- (NSArray*)__split:(id)pattern limit:(NSNumber*)limitNum
+{
+ NSString* target = self;
+
+ if (![pattern isKindOfClass:[OnigRegexp class]]) {
+ if ([pattern isEqual:@" "]) {
+ // If the pattern is a single space,
+ // split by contiguous white spaces,
+ // where leading and trailing white spaces are ignored.
+
+ NSRange r = [target rangeOfRegexp:@"^\\s+"];
+ if (r.location != NSNotFound) {
+ target = [target substringFromIndex:NSMaxRange(r)];
+ }
+ r = [target rangeOfRegexp:@"\\s+$"];
+ if (r.location != NSNotFound) {
+ target = [target substringToIndex:r.location];
+ }
+ pattern = [OnigRegexp compile:@"\\s+"];
+ } else {
+ pattern = [OnigRegexp compile:(NSString*)pattern];
+ }
+ }
+
+ int i = 0;
+ int limit = 0;
+
+ if (limitNum) {
+ limit = [limitNum intValue];
+ if (limit <=0) {
+ limitNum = nil;
+ } else if (limit == 1) {
+ if ([target length] == 0) return [NSArray array];
+ return [NSArray arrayWithObjects:[[target copy] autorelease], nil];
+ }
+ i = 1;
}
NSMutableArray* array = [NSMutableArray array];
- int n = 0;
+ int start = 0;
+ int begin = 0;
+ BOOL lastNull = NO;
+
OnigResult* res;
- while (res = [expression search:self start:n]) {
+ while (res = [pattern search:target start:start]) {
NSRange range = [res bodyRange];
- [array addObject:[self substringWithRange:NSMakeRange(n, range.location - n)]];
- n = NSMaxRange(range);
+ int end = range.location;
+ int right = NSMaxRange(range);
+
+ if (start == end && range.length == 0) {
+ if ([target length] == 0) {
+ [array addObject:@""];
+ break;
+ } else if (lastNull) {
+ [array addObject:[target substringWithRange:NSMakeRange(begin, 1)]];
+ begin = start;
+ } else {
+ start++;
+ lastNull = YES;
+ continue;
+ }
+ } else {
+ [array addObject:[target substringWithRange:NSMakeRange(begin, end-begin)]];
+ begin = start = right;
+ }
+ lastNull = NO;
+
+ if (limitNum && limit <= ++i) break;
}
- if (n < [self length]) {
- [array addObject:[self substringFromIndex:n]];
+
+ if ([target length] > 0 && (limitNum || [target length] > begin || limit < 0)) {
+ if ([target length] == begin) {
+ [array addObject:@""];
+ } else {
+ [array addObject:[target substringFromIndex:begin]];
+ }
+ }
+
+ if (!limitNum && limit == 0) {
+ NSString* last;
+ while ((last = [array lastObject]) && [last length] == 0) {
+ [array removeLastObject];
+ }
}
+
return array;
}
-@end
-
-
-@implementation NSMutableString (OnigRegexpUtility)
-
-- (BOOL)replaceByRegexp:(id)expression with:(NSString*)string
+- (NSString*)replaceByRegexp:(id)pattern with:(NSString*)string
{
- if (![expression isKindOfClass:[OnigRegexp class]]) {
- expression = [OnigRegexp compile:(NSString*)expression];
+ if (![pattern isKindOfClass:[OnigRegexp class]]) {
+ pattern = [OnigRegexp compile:(NSString*)pattern];
}
- OnigResult* res = [expression search:self];
+ OnigResult* res = [pattern search:self];
if (res) {
- [self replaceCharactersInRange:[res bodyRange] withString:string];
- return YES;
+ NSMutableString* s = [[self mutableCopy] autorelease];
+ [s replaceCharactersInRange:[res bodyRange] withString:string];
+ return s;
} else {
- return NO;
+ return [[self mutableCopy] autorelease];
}
}
-- (int)replaceAllByRegexp:(id)expression with:(NSString*)string
+//
+// This implementation is based on ruby 1.8.
+//
+
+- (NSString*)replaceAllByRegexp:(id)pattern with:(NSString*)string
{
- if (![expression isKindOfClass:[OnigRegexp class]]) {
- expression = [OnigRegexp compile:(NSString*)expression];
+ if (![pattern isKindOfClass:[OnigRegexp class]]) {
+ pattern = [OnigRegexp compile:(NSString*)pattern];
+ }
+
+ OnigResult* res = [pattern search:self];
+ if (!res) {
+ return [[self mutableCopy] autorelease];
}
- OnigResult* res;
- int n = 0;
- int count = 0;
- while (res = [expression search:self start:n]) {
+ NSMutableString* s = [NSMutableString string];
+ int offset = 0;
+
+ do {
NSRange range = [res bodyRange];
- [self replaceCharactersInRange:range withString:string];
- int next = range.location + [string length];
- if (n == next) next++;
- n = next;
- count++;
- if ([self length] <= n) break;
+ int len = range.location-offset;
+ if (len > 0) [s appendString:[self substringWithRange:NSMakeRange(offset, len)]];
+ [s appendString:string];
+
+ offset = NSMaxRange(range);
+ if (range.length == 0) {
+ // consume 1 character at least
+ if ([self length] <= offset) break;
+ [s appendString:[self substringWithRange:NSMakeRange(offset, 1)]];
+ offset++;
+ }
+ if ([self length] < offset) break;
+
+ } while (res = [pattern search:self start:offset]);
+
+ if (offset < [self length]) {
+ [s appendString:[self substringFromIndex:offset]];
}
- return count;
+
+ return s;
+}
+
+@end
+
+
+@implementation NSMutableString (OnigRegexpNSMutableStringUtility)
+
+- (NSMutableString*)replaceByRegexp:(id)pattern with:(NSString*)string
+{
+ return (NSMutableString*)[super replaceByRegexp:pattern with:string];
+}
+
+- (NSMutableString*)replaceAllByRegexp:(id)pattern with:(NSString*)string
+{
+ return (NSMutableString*)[super replaceAllByRegexp:pattern with:string];
}
@end
View
37 framework/testcommand/main.m
@@ -0,0 +1,37 @@
+#import <Foundation/Foundation.h>
+#import <CocoaOniguruma/OnigRegexp.h>
+
+int main()
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+/*
+ NSLog(@"%@", [@" now's the time" split]);
+ NSLog(@"%@", [@" now's the time" splitByRegexp:@" "]);
+ NSLog(@"%@", [@" now's the time" splitByRegexp:[OnigRegexp compile:@" "]]);
+ NSLog(@"%@", [@"1, 2.34,56, 7" splitByRegexp:@",\\s*"]);
+ NSLog(@"%@", [@"hello" splitByRegexp:@""]);
+ NSLog(@"%@", [@"hello" splitByRegexp:@"" limit:3]);
+ NSLog(@"%@", [@"hi mom" splitByRegexp:@"\\s*"]);
+ NSLog(@"%@", [@"mellow yellow" splitByRegexp:@"ello"]);
+ NSLog(@"%@", [@"1,2,,3,4,," splitByRegexp:@","]);
+ NSLog(@"%@", [@"1,2,,3,4,," splitByRegexp:@"," limit:4]);
+ NSLog(@"%@", [@"1,2,,3,4,," splitByRegexp:@"," limit:-4]);
+ NSLog(@"%@", [@"h ello" splitByRegexp:@"\\s*" limit:3]);
+ NSLog(@"%@", [@"a,b,c" splitByRegexp:@","]);
+ NSLog(@"%@", [@"a,b,,c" splitByRegexp:@","]);
+ NSLog(@"%@", [@"a,b, c" splitByRegexp:@",\\s*"]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@""]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"^"]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"$"]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"^" limit:-1]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"$" limit:-1]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"."]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"." limit:-1]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@""]);
+ NSLog(@"%@", [@"abc" splitByRegexp:@"" limit:-1]);
+*/
+
+ [pool release];
+ return 0;
+}
View
4 framework/tests/OnigRegexpTest.h
@@ -0,0 +1,4 @@
+#import <SenTestingKit/SenTestingKit.h>
+
+@interface OnigRegexpTest : SenTestCase
+@end
View
121 framework/tests/OnigRegexpTest.m
@@ -0,0 +1,121 @@
+#import "OnigRegexpTest.h"
+#import "CocoaOniguruma/OnigRegexp.h"
+
+@implementation OnigRegexpTest
+
+- (void)testSurrogatePairs
+{
+ OnigRegexp* e = [OnigRegexp compile:@"[^a-z0-9_\\s]"];
+ OnigResult* r = [e search:[NSString stringWithUTF8String:"012_\xf0\xa3\x8f\x90 abc"]];
+
+ STAssertNotNil(r, nil);
+ STAssertEquals([r bodyRange], NSMakeRange(4,2), nil);
+ STAssertEqualObjects([r body], [NSString stringWithUTF8String:"\xf0\xa3\x8f\x90"], nil);
+ STAssertEqualObjects([r preMatch], @"012_", nil);
+ STAssertEqualObjects([r postMatch], @" abc", nil);
+}
+
+- (void)testNamedCaptures
+{
+ OnigRegexp* e = [OnigRegexp compile:@"(?<digits>\\d+)[^\\d]+(?<digits>\\d+)[^a-zA-Z\\d]*(?<letters>[a-zA-Z]+)"];
+ OnigResult* r = [e search:@" 012/345 \\t abc##"];
+
+ STAssertNotNil(r, nil);
+ STAssertEquals(NSMakeRange(2,11), [r bodyRange], nil);
+ STAssertEquals([r count], 4, nil);
+ STAssertEquals([r indexForName:@"digits"], 1, nil);
+ STAssertEqualObjects([r indexesForName:@"digits"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,2)], nil);
+ STAssertEquals([r indexForName:@"letters"], 3, nil);
+ STAssertEqualObjects([r indexesForName:@"letters"], [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(3,1)], nil);
+ STAssertEqualObjects([r stringForName:@"digits"], @"012", nil);
+
+ NSArray* ary = [r stringsForName:@"digits"];
+ NSArray* expected = [NSArray arrayWithObjects:@"012", @"345", nil];
+ STAssertEqualObjects(ary, expected, nil);
+}
+
+- (void)testSearch
+{
+ OnigRegexp* e = [OnigRegexp compile:@"[a-z]+"];
+ OnigResult* r = [e search:@" 012xyz abc789"];
+
+ STAssertEquals([r bodyRange], NSMakeRange(4,3), nil);
+ STAssertEqualObjects([r body], @"xyz", nil);
+}
+
+- (void)testMatch
+{
+ OnigRegexp* e = [OnigRegexp compile:@"[a-z]+"];
+ OnigResult* r = [e match:@"abcABC"];
+
+ STAssertEquals(NSMakeRange(0,3), [r bodyRange], nil);
+ STAssertEqualObjects(@"abc", [r body], nil);
+}
+
+- (void)testRangeOfRegexp
+{
+ STAssertEquals([@"" rangeOfRegexp:@"^"], NSMakeRange(0,0), nil);
+ STAssertEquals([@"" rangeOfRegexp:[OnigRegexp compile:@"^"]], NSMakeRange(0,0), nil);
+ STAssertEquals([@" 0 abc xyz" rangeOfRegexp:@"[a-z]+"], NSMakeRange(3,3), nil);
+ STAssertEquals([@" 0 abc xyz" rangeOfRegexp:[OnigRegexp compile:@"[a-z]+"]], NSMakeRange(3,3), nil);
+ STAssertEquals([@"abc" rangeOfRegexp:@"[^a-z]+"], NSMakeRange(NSNotFound,0), nil);
+ STAssertEquals([@"abc" rangeOfRegexp:[OnigRegexp compile:@"[^a-z]+"]], NSMakeRange(NSNotFound,0), nil);
+}
+
+// These tests are based on ruby 1.8's source code.
+
+- (void)testSplit
+{
+ NSArray* expected;
+
+ expected = [NSArray arrayWithObjects:@"now's", @"the", @"time", nil];
+ STAssertEqualObjects([@" now's the time" split], expected, nil);
+ STAssertEqualObjects([@" now's the time" splitByRegexp:@" "], expected, nil);
+ expected = [NSArray arrayWithObjects:@"", @"now's", @"", @"the", @"time", nil];
+ STAssertEqualObjects([@" now's the time" splitByRegexp:[OnigRegexp compile:@" "]], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"1", @"2.34", @"56", @"7", nil];
+ STAssertEqualObjects([@"1, 2.34,56, 7" splitByRegexp:@",\\s*"], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"h", @"e", @"l", @"l", @"o", nil];
+ STAssertEqualObjects([@"hello" splitByRegexp:@""], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"h", @"e", @"llo", nil];
+ STAssertEqualObjects([@"hello" splitByRegexp:@"" limit:3], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"h", @"i", @"m", @"o", @"m", nil];
+ STAssertEqualObjects([@"hi mom" splitByRegexp:@"\\s*"], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"m", @"w y", @"w", nil];
+ STAssertEqualObjects([@"mellow yellow" splitByRegexp:@"ello"], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3", @"4", nil];
+ STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@","], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3,4,,", nil];
+ STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:4], expected, nil);
+
+ expected = [NSArray arrayWithObjects:@"1", @"2", @"", @"3", @"4", @"", @"", nil];
+ STAssertEqualObjects([@"1,2,,3,4,," splitByRegexp:@"," limit:-4], expected, nil);
+}
+
+- (void)testReplace
+{
+ STAssertEqualObjects([@"" replaceByRegexp:@"" with:@""], @"", nil);
+ STAssertEqualObjects([@"" replaceByRegexp:@"" with:@"_"], @"_", nil);
+ STAssertEqualObjects([@"" replaceByRegexp:@"0" with:@"_"], @"", nil);
+ STAssertEqualObjects([@"abc" replaceByRegexp:@"" with:@"_"], @"_abc", nil);
+ STAssertEqualObjects([@"abc" replaceByRegexp:@"$" with:@"_"], @"abc_", nil);
+ STAssertEqualObjects([@"aa 00 aa 11" replaceByRegexp:@"\\d+" with:@"digits"], @"aa digits aa 11", nil);
+}
+
+- (void)testReplaceAll
+{
+ STAssertEqualObjects([@"abc" replaceAllByRegexp:@"" with:@"_"], @"_a_b_c_", nil);
+ STAssertEqualObjects([@"abc" replaceAllByRegexp:@"^" with:@"_"], @"_abc", nil);
+ STAssertEqualObjects([@"abc" replaceAllByRegexp:@"$" with:@"_"], @"abc_", nil);
+ STAssertEqualObjects([@"abc" replaceAllByRegexp:@"." with:@"_"], @"___", nil);
+ STAssertEqualObjects([@"aa 00 aa 11" replaceAllByRegexp:@"\\d+" with:@"digits"], @"aa digits aa digits", nil);
+}
+
+@end
View
23 readme.txt
@@ -17,14 +17,16 @@ Follow the steps to use CocoaOniguruma in your project.
* How to use as a Framework
-1. Build CocoaOniguruma.xcodeproj by Xcode.
-2. Copy "build/Release/CocoaOniguruma.framework" into your project directory.
-3. Open your project by Xcode.
-4. Add the framework to your project under "Frameworks".
-5. Open "Targets" in the project tree.
-6. Right click on the application target to open context menu and add a "New Copy Files Build Phase".
-7. Drag "CocoaOniguruma.framework" into the new "Copy Files" phase.
-8. Import the header file, so you can use CocoaOniguruma.
+ 1. Open CocoaOniguruma.xcodeproj by Xcode.
+ 2. Select "CocoaOniguruma" for Active Target and "Release" for Active Build Configuration.
+ 3. Build it.
+ 4. Copy "build/Release/CocoaOniguruma.framework" into your project directory.
+ 5. Open your project by Xcode.
+ 6. Add the framework to your project under "Frameworks".
+ 7. Open "Targets" in the project tree.
+ 8. Right click on the application target to open context menu and add a "New Copy Files Build Phase".
+ 9. Drag "CocoaOniguruma.framework" into the new "Copy Files" phase.
+10. Import the header file, so you can use CocoaOniguruma.
#import "CocoaOniguruma/OnigRegexp.h"
* The Author
@@ -33,6 +35,11 @@ Satoshi Nakagawa <psychs AT limechat DOT net>
http://d.hatena.ne.jp/Psychs/ (in Japanese)
#limechat on irc.freenode.net
+* Thanks
+
+The specifications and implementations of split and replace functions are based on ruby 1.8.
+Thanks to Matz.
+
* License
CocoaOniguruma contains a part of Oniguruma 5.9.1 source code currently.
Please sign in to comment.
Something went wrong with that request. Please try again.