Author: wlux
Date: Sat Feb 11 15:24:58 2017
New Revision: 40333
URL: http://svn.gna.org/viewcvs/gnustep?rev=40333&view=rev
Log:
Fix a serious misunderstanding of the icu string access API: The value
of nativeIndexingLimit must not exceed the length of the current chunk.
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/GSICUString.m
libs/base/trunk/Source/NSRegularExpression.m
libs/base/trunk/Tests/base/NSRegularExpression/basic.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=40333&r1=40332&r2=40333&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Sat Feb 11 15:24:58 2017
@@ -1,3 +1,13 @@
+2017-02-11 Wolfgang Lux <[email protected]>
+
+ * Source/GSICUString.m (UTextNSStringAccess,
+ UTextInitWithNSMutableString, UTextInitWithNSString):
+ Fix a serious misunderstanding of the icu string access API: The
+ value of nativeIndexingLimit must not exceed the length of the
+ current chunk. Otherwise icu library macros could miss to properly
+ reinitialize chunks, which, for instance, could lead to returning
+ regular expression matches outside the selected range.
+
2017-01-06 Richard Frith-Macdonald <[email protected]>
* Tools/gdomap.c: Use getaddrinfo rather than gethostbyname if
Modified: libs/base/trunk/Source/GSICUString.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSICUString.m?rev=40333&r1=40332&r2=40333&view=diff
==============================================================================
--- libs/base/trunk/Source/GSICUString.m (original)
+++ libs/base/trunk/Source/GSICUString.m Sat Feb 11 15:24:58 2017
@@ -130,6 +130,7 @@
[str getCharacters: ut->pExtra range: r];
ut->chunkNativeLimit = nativeLimit;
ut->chunkNativeStart = nativeStart;
+ ut->nativeIndexingLimit = r.length;
ut->chunkLength = r.length;
return TRUE;
}
@@ -378,7 +379,6 @@
txt->p = [str retain];
txt->pFuncs = &NSMutableStringFuncs;
txt->chunkContents = txt->pExtra;
- txt->nativeIndexingLimit = INT32_MAX;
txt->c = -1; // Need to fetch length every time
txt->providerProperties = 1<<UTEXT_PROVIDER_WRITABLE;
@@ -399,7 +399,6 @@
txt->p = [str retain];
txt->pFuncs = &NSStringFuncs;
txt->chunkContents = txt->pExtra;
- txt->nativeIndexingLimit = INT32_MAX;
txt->c = [str length];
return txt;
Modified: libs/base/trunk/Source/NSRegularExpression.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSRegularExpression.m?rev=40333&r1=40332&r2=40333&view=diff
==============================================================================
--- libs/base/trunk/Source/NSRegularExpression.m (original)
+++ libs/base/trunk/Source/NSRegularExpression.m Sat Feb 11 15:24:58 2017
@@ -31,7 +31,7 @@
/* FIXME It would be nice to use autoconf for checking whether uregex_openUText
* is defined. However the naive check using AC_CHECK_FUNCS(uregex_openUText)
- * wonn't work because libicu internally renames all entry points with some cpp
+ * won't work because libicu internally renames all entry points with some cpp
* magic.
*/
#if (U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 &&
U_ICU_VERSION_MINOR_NUM >= 4))
Modified: libs/base/trunk/Tests/base/NSRegularExpression/basic.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSRegularExpression/basic.m?rev=40333&r1=40332&r2=40333&view=diff
==============================================================================
--- libs/base/trunk/Tests/base/NSRegularExpression/basic.m (original)
+++ libs/base/trunk/Tests/base/NSRegularExpression/basic.m Sat Feb 11
15:24:58 2017
@@ -2,6 +2,7 @@
#import "ObjectTesting.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSRegularExpression.h>
+#import <Foundation/NSTextCheckingResult.h>
#import <Foundation/NSDate.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSUserDefaults.h>
@@ -129,6 +130,17 @@
template: @"c"];
PASS_EQUAL(replacement, @"c",
"Custom replacement: Returns correct replacement");
+
+ NSRegularExpression *testObj2 =
+ [[NSRegularExpression alloc] initWithPattern: @"bc"
+ options: 0
+ error: NULL];
+ r = [testObj2 firstMatchInString: @"abcdeabcde"
+ options: 0
+ range: NSMakeRange(5, 5)];
+ PASS(r != nil && NSEqualRanges([r range], NSMakeRange(6, 2)),
+ "Restricting the range for firstMatchInString: works");
+
/* To test whether we correctly bail out of processing degenerate patterns,
* we spin up a new thread and evaluate an expression there. The expectation
* is that the thread should terminate within a few seconds.
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs