<font size=2 face="sans-serif">Hi Tony,</font><br><br><font size=2 face="sans-serif">Thank you for the comments.</font><br><br><font size=2 face="sans-serif">PR is created: </font><a href="https://github.com/apple/swift-corelibs-foundation/pull/282"><font size=2 color=blue face="sans-serif">https://github.com/apple/swift-corelibs-foundation/pull/282</font></a><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;"><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;"><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></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;"><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;"><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;"><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 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;"><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;"><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;"><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;"><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 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;"></table><br><font size=2 face="sans-serif"><br></font><br><br><br><br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">Tony Parker <anthony.parker@apple.com></font><br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Mamatha Busi/India/IBM@IBMIN</font><br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">Philippe Hausler <phausler@apple.com>,
swift-corelibs-dev@swift.org</font><br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">03/08/2016 11:11 PM</font><br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [swift-corelibs-dev]
NSRegularExpression.firstMatchInString() fails on
Linux</font><br><font size=1 color=#5f5f5f face="sans-serif">Sent by:
</font><font size=1 face="sans-serif">anthony.parker@apple.com</font><br><hr noshade><br><br><br><font size=3>Hi Mamatha,</font><br><br><font size=3>On Mar 8, 2016, at 4:15 AM, Mamatha Busi <</font><a href=mailto:mamabusi@in.ibm.com><font size=3 color=blue><u>mamabusi@in.ibm.com</u></font></a><font size=3>>
wrote:</font><br><br><font size=2 face="sans-serif"> @Philippe Hausler, @Tony Parker:
Thank you for the response. </font><font size=3><br></font><font size=2 face="sans-serif"><br>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"> (the
place where the ranges are being constructed). Below is the code snippet
with the changes:</font><font size=3><br></font><font size=2 face="sans-serif"><br> _regularExpression = regularExpression<br> super.init()<br> <b>let notFound = NSRange(location: NSNotFound,length:
0)</b><br> for i in 0..<count {<br> <b>ranges[i].location == kCFNotFound
? _ranges.append(notFound) : _ranges.append(ranges[i])</b><br> }</font><font size=3><br></font><font size=2 face="sans-serif"><br>@Philippe: Request your comments on the above code changes.</font><font size=3><br></font><font size=2 face="sans-serif"><br>TestFoundation has been run and I see no failures with the above changes.</font><font size=3><br></font><font size=2 face="sans-serif"><br>The tests 'test_complexRegularExpressions' in the 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><font size=3><br></font><br><br><font size=3>Sure, more tests are always a bonus.</font><br><br><font size=3>Please open a PR on swift-corelibs-foundatation when you’re
ready to get a review.</font><br><br><font size=3>Thanks for tackling this!</font><br><font size=3>- Tony</font><br><br><font size=2 face="sans-serif">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><Mail Attachment.gif></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"> </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">
</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">
</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">
</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">
</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">
</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=3><br><br><br><br></font><font size=1 color=#5f5f5f face="sans-serif"><br>From: </font><font size=1 face="sans-serif">Philippe
Hausler <</font><a href=mailto:phausler@apple.com><font size=1 color=blue face="sans-serif"><u>phausler@apple.com</u></font></a><font size=1 face="sans-serif">></font><font size=1 color=#5f5f5f face="sans-serif"><br>To: </font><font size=1 face="sans-serif">Tony
Parker <</font><a href=mailto:anthony.parker@apple.com><font size=1 color=blue face="sans-serif"><u>anthony.parker@apple.com</u></font></a><font size=1 face="sans-serif">></font><font size=1 color=#5f5f5f face="sans-serif"><br>Cc: </font><font size=1 face="sans-serif">Mamatha
Busi/India/IBM@IBMIN, </font><a href="mailto:swift-corelibs-dev@swift.org"><font size=1 color=blue face="sans-serif"><u>swift-corelibs-dev@swift.org</u></font></a><font size=1 color=#5f5f5f face="sans-serif"><br>Date: </font><font size=1 face="sans-serif">03/04/2016
12:02 AM</font><font size=1 color=#5f5f5f face="sans-serif"><br>Subject: </font><font size=1 face="sans-serif">Re:
[swift-corelibs-dev] NSRegularExpression.firstMatchInString() fails
on Linux</font><font size=1 color=#5f5f5f face="sans-serif"><br>Sent by: </font><a href=mailto:phausler@apple.com><font size=1 color=blue face="sans-serif"><u>phausler@apple.com</u></font></a><font size=3><br></font><hr noshade><font size=3><br><br><br><br>On Mar 3, 2016, at 10:22 AM, Tony Parker via swift-corelibs-dev <</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>>
wrote:<br></font><font size=1 face="Helvetica"><br>Hi Mamatha,</font><font size=3><br></font><font size=1 face="Helvetica"><br>On Mar 2, 2016, at 3:57 AM, Mamatha Busi via swift-corelibs-dev <</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">>
wrote:</font><font size=3><br></font><font size=2 face="sans-serif"><br>Hello<br><br>The following test case, that currently fails on Linux, is extracted
from some of the excluded tests inside TestFoundation/TestNSRegularExpression.
<br><br>import Foundation<br><br>let searchStr = "123"<br>let testRegex = try NSRegularExpression.init(pattern: "a(b|c|d)(x|y|z)*|123",
options: [])<br>let firstMatch = testRegex.firstMatchInString(searchStr, options: [], range:
NSMakeRange(0,3))<br><br>if NSEqualRanges((firstMatch!.rangeAtIndex(1), NSMakeRange(NSNotFound,0))
{<br> print("Test passed")<br>} else {<br> print("First match first capture range = \(NSStringFromRange(firstMatch!.rangeAtIndex(1)))")<br> print("Test failed")<br>}</font><font size=1 face="Helvetica"><br><br></font><font size=2 face="sans-serif"><br><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.<br><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).<br><br>There are a couple of queries that I have:<br><br>-> Is 'NSNotFound' in Foundation mapped to 'kCFNotFound' in
CoreFoundation?</font><font size=3><br></font><font size=2 face="sans-serif"><br>-> If so, then why do 'NSNotFound' and 'kCFNotFound' have different
values on the Foundation and CoreFoundation respectively?</font><font size=3><br><br></font><font size=1 face="Helvetica"><br>They don’t have the same value; we translate it manually in most places.</font><font size=3><br></font><font size=2 face="sans-serif"><br>Also, I tested by modifying the 'kCFNotFound' value in CoreFoundation/Base.subproj/CFBase.h
(See below code snippet):<br><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></font><font size=2 face="sans-serif"><br><br>With this change the above mentioned test-case passes but a lot of other
TestFoundation tests seem to fail.<br><br>Please provide your comments on the appropriate change that is needed here.
<br><br>Thank you.</font><font size=3><br></font><font size=1 face="Helvetica"><br>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><font size=3><br><br>I think the problem in this case is that we fetch a buffer of CFRanges
and pass that to the result creation.<br><br>ranges: UnsafeMutablePointer<CFRange><br>...<br>let result = NSTextCheckingResult.regularExpressionCheckingResultWithRanges(NSRangePointer(ranges),
count: count, regularExpression: matcher.regex)<br><br></font><font size=1 face="Helvetica"><br>Thanks,<br>- Tony</font><font size=3><br></font><font size=2 face="sans-serif"><br><br>Regards<br>Mamatha</font><table width=599 style="border-collapse:collapse;"><tr height=8><td width=597 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=597 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=349 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><Mail Attachment.gif></font></div><tr height=8><td width=349 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=349 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"> </font><tr height=8><td width=349 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"> </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"> </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"> </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"> </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=349 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"> </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=597 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>_______________________________________________<br>swift-corelibs-dev mailing list</font><font size=3 color=blue><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=3 color=blue><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><font size=3><br></font><font size=1 face="Helvetica"><br>_______________________________________________<br>swift-corelibs-dev mailing list</font><font size=3 color=blue><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=3 color=blue><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><font size=3><br><br></font><br><br><BR>