Author: thebeing
Date: Tue Sep  1 13:31:16 2015
New Revision: 38963

URL: http://svn.gna.org/viewcvs/gnustep?rev=38963&view=rev
Log:
Fix handling of capture groups not participating in the current match. 

The Cocoa API specifies to return theses as (NSNotFound,0) ranges, but the
ICU API returns them as (-1,-1) pairs of start/end indices. The necessary
conversion was missing here.

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Source/NSRegularExpression.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=38963&r1=38962&r2=38963&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Tue Sep  1 13:31:16 2015
@@ -1,3 +1,7 @@
+2015-09-01 Niels Grewe <[email protected]>
+
+       * Source/NSRegularExpression.m: Fix handling of empty capture groups.
+
 2015-08-30  Richard Frith-Macdonald <[email protected]>
 
        * Source/NSOperation.m: Fix potential deadlock with adding observers.

Modified: libs/base/trunk/Source/NSRegularExpression.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSRegularExpression.m?rev=38963&r1=38962&r2=38963&view=diff
==============================================================================
--- libs/base/trunk/Source/NSRegularExpression.m        (original)
+++ libs/base/trunk/Source/NSRegularExpression.m        Tue Sep  1 13:31:16 2015
@@ -297,8 +297,18 @@
 
   for (i = 0; i < groups; i++)
     {
-      NSUInteger start = uregex_start(r, i, s);
-      NSUInteger end = uregex_end(r, i, s);
+      NSInteger start = uregex_start(r, i, s);
+      NSInteger end = uregex_end(r, i, s);
+      // The ICU API defines -1 as not found. Convert to
+      // NSNotFound if applicable.
+      if (start == -1)
+        {
+          start = NSNotFound;
+        }
+      if (end == -1)
+        {
+          end = NSNotFound;
+        }
 
       if (end < start)
         {


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to