<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Mamatha,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 8, 2016, at 4:15 AM, Mamatha Busi <<a href="mailto:mamabusi@in.ibm.com" class="">mamabusi@in.ibm.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font size="2" face="sans-serif" class=""> @Philippe Hausler, @Tony Parker:
Thank you for the response. </font><br class=""><br class=""><font size="2" face="sans-serif" class="">As per Tony's suggestions I have translated
CF's kCFNotFound into an NSNotFound of Foundation in '</font><font size="3" class="">NSTextCheckingResult'
</font><font size="2" face="sans-serif" class=""> (the place where the ranges
are being constructed). Below is the code snippet with the changes:</font><br class=""><br class=""><font size="2" face="sans-serif" class=""> _regularExpression = regularExpression</font><br class=""><font size="2" face="sans-serif" class=""> super.init()</font><br class=""><font size="2" face="sans-serif" class=""> <b class="">let notFound
= NSRange(location: NSNotFound,length: 0)</b></font><br class=""><font size="2" face="sans-serif" class=""> for i in
0..<count {</font><br class=""><font size="2" face="sans-serif" class="">
<b class="">ranges[i].location == kCFNotFound ? _ranges.append(notFound) : _ranges.append(ranges[i])</b></font><br class=""><font size="2" face="sans-serif" class=""> }</font><br class=""><br class=""><font size="2" face="sans-serif" class="">@Philippe: Request your comments on
the above code changes.</font><br class=""><br class=""><font size="2" face="sans-serif" class="">TestFoundation has been run and I see
no failures with the above changes.</font><br class=""><br class=""><font size="2" face="sans-serif" class="">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><br class=""><br class=""></div></blockquote><div><br class=""></div><div>Sure, more tests are always a bonus.</div><div><br class=""></div><div>Please open a PR on swift-corelibs-foundatation when you’re ready to get a review.</div><div><br class=""></div><div>Thanks for tackling this!</div><div>- Tony</div><br class=""><blockquote type="cite" class=""><div class=""><font size="2" face="sans-serif" class="">Regards</font><br class=""><font size="2" face="sans-serif" class="">Mamatha</font><br class=""><table width="600" style="border-collapse:collapse;" class=""><tbody class=""><tr height="8" class=""><td width="600" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><hr class=""></td></tr><tr height="8" class=""><td width="600" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="350" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="2" face="Arial" class=""><b class="">Mamatha
Busi</b></font></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td><td width="119" rowspan="3" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><div align="right" class=""><span id="cid:_1_0E506AC00E5066EC00435CAB65257F70"><Mail Attachment.gif></span></div></td></tr><tr height="8" class=""><td width="350" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">Java
L3 Support</font></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="350" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">IBM
Software Group</font></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td></tr><tr height="8" class=""><td width="350" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">India
Software Labs</font></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">
</font></td><td width="119" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="75" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td><td width="275" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">
</font></td><td width="119" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="75" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td><td width="275" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">
</font></td><td width="119" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="75" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">e-mail:</font></td><td width="275" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""><a href="mailto:mamabusi@in.ibm.com" class="">mamabusi@in.ibm.com</a></font></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">
</font></td><td width="119" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="350" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><a href="http://bit.ly/a7KpQj" class=""><font size="1" color="blue" face="Arial" class=""><u class="">Java
Technology India Group</u></font></a></td><td width="129" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">
</font></td><td width="119" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""></td></tr><tr height="8" class=""><td width="600" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:0px 0px;" class=""><hr class=""></td></tr></tbody></table><br class=""><font size="2" face="sans-serif" class=""><br class=""></font><br class=""><br class=""><br class=""><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">From:
</font><font size="1" face="sans-serif" class="">Philippe Hausler <<a href="mailto:phausler@apple.com" class="">phausler@apple.com</a>></font><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">To:
</font><font size="1" face="sans-serif" class="">Tony Parker <<a href="mailto:anthony.parker@apple.com" class="">anthony.parker@apple.com</a>></font><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Cc:
</font><font size="1" face="sans-serif" class="">Mamatha Busi/India/IBM@IBMIN,
<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a></font><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Date:
</font><font size="1" face="sans-serif" class="">03/04/2016 12:02 AM</font><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Subject:
</font><font size="1" face="sans-serif" class="">Re: [swift-corelibs-dev]
NSRegularExpression.firstMatchInString() fails on
Linux</font><br class=""><font size="1" color="#5f5f5f" face="sans-serif" class="">Sent by:
</font><font size="1" face="sans-serif" class=""><a href="mailto:phausler@apple.com" class="">phausler@apple.com</a></font><br class=""><hr noshade="" class=""><br class=""><br class=""><br class=""><br class=""><font size="3" class="">On Mar 3, 2016, at 10:22 AM, Tony Parker via swift-corelibs-dev
<</font><a href="mailto:swift-corelibs-dev@swift.org" class=""><font size="3" color="blue" class=""><u class="">swift-corelibs-dev@swift.org</u></font></a><font size="3" class="">>
wrote:</font><br class=""><br class=""><font size="1" face="Helvetica" class="">Hi Mamatha,</font><br class=""><br class=""><font size="1" face="Helvetica" class="">On Mar 2, 2016, at 3:57 AM, Mamatha Busi
via swift-corelibs-dev <</font><a href="mailto:swift-corelibs-dev@swift.org" class=""><font size="1" color="blue" face="Helvetica" class=""><u class="">swift-corelibs-dev@swift.org</u></font></a><font size="1" face="Helvetica" class="">>
wrote:</font><br class=""><br class=""><font size="2" face="sans-serif" class="">Hello</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">The following test case, that currently fails on Linux, is extracted
from some of the excluded tests inside TestFoundation/TestNSRegularExpression.
</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">import Foundation</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">let searchStr = "123"<br class="">let testRegex = try NSRegularExpression.init(pattern: "a(b|c|d)(x|y|z)*|123",
options: [])<br class="">let firstMatch = testRegex.firstMatchInString(searchStr, options: [], range:
NSMakeRange(0,3))</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">if NSEqualRanges((firstMatch!.rangeAtIndex(1), NSMakeRange(NSNotFound,0))
{<br class=""> print("Test passed")<br class="">} else {<br class=""> print("First match first capture range = \(NSStringFromRange(firstMatch!.rangeAtIndex(1)))")<br class=""> print("Test failed")<br class="">}</font><font size="1" face="Helvetica" class=""><br class=""><br class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">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" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">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" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">There are a couple of queries that I have:</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">-> Is 'NSNotFound' in Foundation mapped to 'kCFNotFound' in
CoreFoundation?</font><font size="1" face="Helvetica" class=""><br class=""></font><br class=""><font size="2" face="sans-serif" class="">-> If so, then why do 'NSNotFound'
and 'kCFNotFound' have different values on the Foundation and CoreFoundation
respectively?</font><font size="1" face="Helvetica" class=""><br class=""></font><br class=""><br class=""><font size="1" face="Helvetica" class="">They don’t have the same value; we translate
it manually in most places.</font><br class=""><br class=""><font size="2" face="sans-serif" class="">Also, I tested by modifying the 'kCFNotFound'
value in CoreFoundation/Base.subproj/CFBase.h (See below code snippet):</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">#if TARGET_RT_64_BIT<br class="">static const CFIndex kCFNotFound = LONG_MAX;<br class="">#else<br class="">static const CFIndex kCFNotFound = INT_MAX;<br class="">#endif</font><font size="1" face="Helvetica" class=""><br class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">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" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">Please provide your comments on the appropriate change that is needed here.
</font><font size="1" face="Helvetica" class=""><br class=""></font><font size="2" face="sans-serif" class=""><br class="">Thank you.</font><br class=""><br class=""><font size="1" face="Helvetica" class="">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 class=""><br class=""><font size="3" class="">I think the problem in this case is that we fetch a buffer
of CFRanges and pass that to the result creation.</font><br class=""><br class=""><font size="3" class="">ranges: UnsafeMutablePointer<CFRange></font><br class=""><font size="3" class="">...</font><br class=""><font size="3" class="">let result = NSTextCheckingResult.regularExpressionCheckingResultWithRanges(NSRangePointer(ranges),
count: count, regularExpression: matcher.regex)</font><br class=""><br class=""><br class=""><font size="1" face="Helvetica" class="">Thanks,</font><br class=""><font size="1" face="Helvetica" class="">- Tony</font><br class=""><br class=""><font size="2" face="sans-serif" class=""><br class="">Regards<br class="">Mamatha</font><table width="600" style="border-collapse:collapse;" class=""><tbody class=""><tr height="8" class=""><td width="598" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><hr class=""></td></tr><tr height="8" class=""><td width="598" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="348" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="2" face="Arial" class=""><b class="">Mamatha
Busi</b></font></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td><td width="118" rowspan="3" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><div align="right" class=""><font size="3" class=""><Mail Attachment.gif></font></div></td></tr><tr height="8" class=""><td width="348" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">Java
L3 Support</font></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="348" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">IBM
Software Group</font></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td></tr><tr height="8" class=""><td width="348" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">India
Software Labs</font></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td><td width="118" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="74" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td><td width="272" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td><td width="118" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="74" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td><td width="272" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td><td width="118" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="74" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class="">e-mail:</font></td><td width="272" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><a href="mailto:mamabusi@in.ibm.com" class=""><font size="1" color="blue" face="Arial" class=""><u class="">mamabusi@in.ibm.com</u></font></a></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td><td width="118" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="348" colspan="2" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><a href="http://bit.ly/a7KpQj" class=""><font size="1" color="blue" face="Arial" class=""><u class="">Java
Technology India Group</u></font></a></td><td width="126" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><font size="1" color="#5f5f5f" face="Arial" class=""> </font></td><td width="118" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""></td></tr><tr height="8" class=""><td width="598" colspan="4" style="border-style:none none none none;border-color:#000000;border-width:0px 0px 0px 0px;padding:1px 1px;" class=""><hr class=""></td></tr></tbody></table><br class=""><font size="2" face="sans-serif" class=""><br class=""></font><font size="1" face="Helvetica" class=""><br class=""><br class="">_______________________________________________<br class="">swift-corelibs-dev mailing list</font><font size="1" color="blue" face="Helvetica" class=""><u class=""><br class=""></u></font><a href="mailto:swift-corelibs-dev@swift.org" class=""><font size="1" color="blue" face="Helvetica" class=""><u class="">swift-corelibs-dev@swift.org</u></font></a><font size="1" color="blue" face="Helvetica" class=""><u class=""><br class=""></u></font><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class=""><font size="1" color="blue" face="Helvetica" class=""><u class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</u></font></a><br class=""><br class=""><font size="1" face="Helvetica" class="">_______________________________________________<br class="">swift-corelibs-dev mailing list</font><font size="1" color="blue" face="Helvetica" class=""><u class=""><br class=""></u></font><a href="mailto:swift-corelibs-dev@swift.org" class=""><font size="1" color="blue" face="Helvetica" class=""><u class="">swift-corelibs-dev@swift.org</u></font></a><font size="1" color="blue" face="Helvetica" class=""><u class=""><br class=""></u></font><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class=""><font size="1" color="blue" face="Helvetica" class=""><u class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</u></font></a><br class=""><br class=""><br class="">
</div></blockquote></div><br class=""></div></body></html>