<font size=2 face="sans-serif">&nbsp;@Philippe Hausler, @Tony Parker:
Thank you for the response. </font><br><br><font size=2 face="sans-serif">As per Tony's suggestions I have translated
CF's kCFNotFound into an NSNotFound of Foundation in '</font><font size=3>NSTextCheckingResult'
</font><font size=2 face="sans-serif">&nbsp;(the place where the ranges
are being constructed). Below is the code snippet with the changes:</font><br><br><font size=2 face="sans-serif">&nbsp;_regularExpression = regularExpression</font><br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; super.init()</font><br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; <b>let notFound
= NSRange(location: NSNotFound,length: 0)</b></font><br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; for i in
0..&lt;count {</font><br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<b>ranges[i].location == kCFNotFound ? _ranges.append(notFound) : _ranges.append(ranges[i])</b></font><br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; }</font><br><br><font size=2 face="sans-serif">@Philippe: Request your comments on
the above code changes.</font><br><br><font size=2 face="sans-serif">TestFoundation has been run and I see
no failures with the above changes.</font><br><br><font size=2 face="sans-serif">The tests 'test_complexRegularExpressions'
in the &nbsp;TestNSRegularExpression were excluded till date. I am now
running the excluded tests as well and there are a few test-cases here
which deal with the ranges having NSNotFound. Along with these should there
be more tests written to test the same? </font><br><br><font size=2 face="sans-serif">Regards</font><br><font size=2 face="sans-serif">Mamatha</font><br><table width=600 style="border-collapse:collapse;"><tr height=8><td width=600 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><hr><tr height=8><td width=600 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=350 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=2 face="Arial"><b>Mamatha
Busi</b></font><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><td width=119 rowspan=3 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><div align=right><img src=cid:_1_0E506AC00E5066EC00435CAB65257F70 style="border:0px solid;"></div><tr height=8><td width=350 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">Java
L3 Support</font><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=350 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">IBM
Software Group</font><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><tr height=8><td width=350 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">India
Software Labs</font><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;
</font><td width=119 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=75 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><td width=275 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;
</font><td width=119 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=75 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><td width=275 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;
</font><td width=119 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=75 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">e-mail:</font><td width=275 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">mamabusi@in.ibm.com</font><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;
</font><td width=119 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=350 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><a href=http://bit.ly/a7KpQj><font size=1 color=blue face="Arial"><u>Java
Technology India Group</u></font></a><td width=129 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;
</font><td width=119 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><tr height=8><td width=600 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;"><hr></table><br><font size=2 face="sans-serif"><br></font><br><br><br><br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Philippe Hausler &lt;phausler@apple.com&gt;</font><br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Tony Parker &lt;anthony.parker@apple.com&gt;</font><br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Mamatha Busi/India/IBM@IBMIN,
swift-corelibs-dev@swift.org</font><br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">03/04/2016 12:02 AM</font><br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [swift-corelibs-dev]
NSRegularExpression.firstMatchInString() fails &nbsp; &nbsp; &nbsp; &nbsp;on
Linux</font><br><font size=1 color=#5f5f5f face="sans-serif">Sent by: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">phausler@apple.com</font><br><hr noshade><br><br><br><br><font size=3>On Mar 3, 2016, at 10:22 AM, Tony Parker via swift-corelibs-dev
&lt;</font><a href="mailto:swift-corelibs-dev@swift.org"><font size=3 color=blue><u>swift-corelibs-dev@swift.org</u></font></a><font size=3>&gt;
wrote:</font><br><br><font size=1 face="Helvetica">Hi Mamatha,</font><br><br><font size=1 face="Helvetica">On Mar 2, 2016, at 3:57 AM, Mamatha Busi
via swift-corelibs-dev &lt;</font><a href="mailto:swift-corelibs-dev@swift.org"><font size=1 color=blue face="Helvetica"><u>swift-corelibs-dev@swift.org</u></font></a><font size=1 face="Helvetica">&gt;
wrote:</font><br><br><font size=2 face="sans-serif">Hello</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>The following test case, that currently fails on Linux, &nbsp;is extracted
from some of the excluded tests inside TestFoundation/TestNSRegularExpression.
</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>import Foundation</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>let searchStr = &quot;123&quot;<br>let testRegex = try NSRegularExpression.init(pattern: &quot;a(b|c|d)(x|y|z)*|123&quot;,
options: [])<br>let firstMatch = testRegex.firstMatchInString(searchStr, options: [], range:
NSMakeRange(0,3))</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>if NSEqualRanges((firstMatch!.rangeAtIndex(1), NSMakeRange(NSNotFound,0))
{<br> &nbsp; &nbsp;print(&quot;Test passed&quot;)<br>} else {<br> &nbsp; &nbsp;print(&quot;First match first capture range = \(NSStringFromRange(firstMatch!.rangeAtIndex(1)))&quot;)<br> &nbsp; &nbsp;print(&quot;Test failed&quot;)<br>}</font><font size=1 face="Helvetica"><br><br><br></font><font size=2 face="sans-serif"><br>In the above scenario, no capture group participates in the match. So,
firstMatch.rangeAtIndex(1) should ideally return range {NSNotFound, 0}
but the actual returned value is range {-1, 0}. Hence the failure.</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>Debugging on the CoreFoundation, it is observed that the value -1 is coming
from 'kCFNotFound' which is defined as -1. On the Foundation side, 'NSNotFound'
is defined with the value of ‘Int.max’ (which must be Int32.max and Int64.max
on 32 and 64 bit platforms respectively).</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>There are a couple of queries that I have:</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>-&gt; Is 'NSNotFound' in Foundation mapped &nbsp;to 'kCFNotFound' &nbsp;in
CoreFoundation?</font><font size=1 face="Helvetica"><br></font><br><font size=2 face="sans-serif">-&gt; If so, then why do 'NSNotFound'
and 'kCFNotFound' have different values on the Foundation and CoreFoundation
respectively?</font><font size=1 face="Helvetica"><br></font><br><br><font size=1 face="Helvetica">They don’t have the same value; we translate
it manually in most places.</font><br><br><font size=2 face="sans-serif">Also, I tested by modifying the 'kCFNotFound'
value in CoreFoundation/Base.subproj/CFBase.h &nbsp;(See below code snippet):</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>#if TARGET_RT_64_BIT<br>static const CFIndex kCFNotFound = LONG_MAX;<br>#else<br>static const CFIndex kCFNotFound = INT_MAX;<br>#endif</font><font size=1 face="Helvetica"><br><br></font><font size=2 face="sans-serif"><br>With this change the above mentioned test-case passes but a lot of other
TestFoundation tests seem to fail.</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>Please provide your comments on the appropriate change that is needed here.
</font><font size=1 face="Helvetica"><br></font><font size=2 face="sans-serif"><br>Thank you.</font><br><br><font size=1 face="Helvetica">I think we probably just need to check
the result from the CF function and translate it into an NSNotFound in
this one particular case.</font><br><br><font size=3>I think the problem in this case is that we fetch a buffer
of CFRanges and pass that to the result creation.</font><br><br><font size=3>ranges: UnsafeMutablePointer&lt;CFRange&gt;</font><br><font size=3>...</font><br><font size=3>let result = NSTextCheckingResult.regularExpressionCheckingResultWithRanges(NSRangePointer(ranges),
count: count, regularExpression: matcher.regex)</font><br><br><br><font size=1 face="Helvetica">Thanks,</font><br><font size=1 face="Helvetica">- Tony</font><br><br><font size=2 face="sans-serif"><br>Regards<br>Mamatha</font><table width=600 style="border-collapse:collapse;"><tr height=8><td width=598 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><hr><tr height=8><td width=598 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=348 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=2 face="Arial"><b>Mamatha
Busi</b></font><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><td width=118 rowspan=3 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><div align=right><font size=3>&lt;Mail Attachment.gif&gt;</font></div><tr height=8><td width=348 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">Java
L3 Support</font><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=348 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">IBM
Software Group</font><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><tr height=8><td width=348 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">India
Software Labs</font><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><td width=118 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=74 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><td width=272 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><td width=118 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=74 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><td width=272 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><td width=118 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=74 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">e-mail:</font><td width=272 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><a href=mailto:mamabusi@in.ibm.com><font size=1 color=blue face="Arial"><u>mamabusi@in.ibm.com</u></font></a><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><td width=118 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=348 colspan=2 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><a href=http://bit.ly/a7KpQj><font size=1 color=blue face="Arial"><u>Java
Technology India Group</u></font></a><td width=126 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><font size=1 color=#5f5f5f face="Arial">&nbsp;</font><td width=118 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><tr height=8><td width=598 colspan=4 style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;"><hr></table><br><font size=2 face="sans-serif"><br></font><font size=1 face="Helvetica"><br><br>_______________________________________________<br>swift-corelibs-dev mailing list</font><font size=1 color=blue face="Helvetica"><u><br></u></font><a href="mailto:swift-corelibs-dev@swift.org"><font size=1 color=blue face="Helvetica"><u>swift-corelibs-dev@swift.org</u></font></a><font size=1 color=blue face="Helvetica"><u><br></u></font><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev"><font size=1 color=blue face="Helvetica"><u>https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</u></font></a><br><br><font size=1 face="Helvetica">_______________________________________________<br>swift-corelibs-dev mailing list</font><font size=1 color=blue face="Helvetica"><u><br></u></font><a href="mailto:swift-corelibs-dev@swift.org"><font size=1 color=blue face="Helvetica"><u>swift-corelibs-dev@swift.org</u></font></a><font size=1 color=blue face="Helvetica"><u><br></u></font><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev"><font size=1 color=blue face="Helvetica"><u>https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</u></font></a><br><br><BR>