<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 2, 2016, at 3:57 AM, Mamatha Busi via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><font size="2" face="sans-serif" class="">Hello</font><br class=""><br class=""><font size="2" face="sans-serif" class="">The following test case, that currently
fails on Linux, is extracted from some of the excluded tests inside
TestFoundation/TestNSRegularExpression. </font><br class=""><br class=""><font size="2" face="sans-serif" class="">import Foundation</font><br class=""><br class=""><font size="2" face="sans-serif" class="">let searchStr = "123"</font><br class=""><font size="2" face="sans-serif" class="">let testRegex = try NSRegularExpression.init(pattern:
"a(b|c|d)(x|y|z)*|123", options: [])</font><br class=""><font size="2" face="sans-serif" class="">let firstMatch = testRegex.firstMatchInString(searchStr,
options: [], range: NSMakeRange(0,3))</font><br class=""><br class=""><font size="2" face="sans-serif" class="">if NSEqualRanges((firstMatch!.rangeAtIndex(1),
NSMakeRange(NSNotFound,0)) {</font><br class=""><font size="2" face="sans-serif" class=""> print("Test passed")</font><br class=""><font size="2" face="sans-serif" class="">} else {</font><br class=""><font size="2" face="sans-serif" class=""> print("First match
first capture range = \(NSStringFromRange(firstMatch!.rangeAtIndex(1)))")</font><br class=""><font size="2" face="sans-serif" class=""> print("Test failed")</font><br class=""><font size="2" face="sans-serif" class="">}</font><br class=""><br class=""><br class=""><br class=""><font size="2" face="sans-serif" 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><br class=""><br class=""><font size="2" face="sans-serif" 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><br class=""><br class=""><font size="2" face="sans-serif" class="">There are a couple of queries that I
have:</font><br class=""><br class=""><font size="2" face="sans-serif" class="">-> Is 'NSNotFound' in Foundation
mapped to 'kCFNotFound' in CoreFoundation?</font><br class=""><br class=""></div></blockquote><blockquote type="cite" class=""><div 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><br class=""><br class=""></div></blockquote><div><br class=""></div>They don’t have the same value; we translate it manually in most places.</div><div class=""><br class=""><blockquote type="cite" class=""><div 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><br class=""><br class=""><font size="2" face="sans-serif" class="">#if TARGET_RT_64_BIT</font><br class=""><font size="2" face="sans-serif" class="">static const CFIndex kCFNotFound = LONG_MAX;</font><br class=""><font size="2" face="sans-serif" class="">#else</font><br class=""><font size="2" face="sans-serif" class="">static const CFIndex kCFNotFound = INT_MAX;</font><br class=""><font size="2" face="sans-serif" class="">#endif</font><br class=""><br class=""><br class=""><font size="2" face="sans-serif" class="">With this change the above mentioned
test-case passes but a lot of other TestFoundation tests seem to fail.</font><br class=""><br class=""><font size="2" face="sans-serif" class="">Please provide your comments on the
appropriate change that is needed here. </font><br class=""><br class=""><font size="2" face="sans-serif" class="">Thank you.</font><br class=""></div></blockquote><div class=""><br class=""></div>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.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">- Tony</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><br 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_10971D9C109719C80041A24165257F6A"><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="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></div></body></html>