<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div><script type="text/javascript" defer="defer">var YAHOO = {'Shortcuts' : {}};
YAHOO.Shortcuts.hasSensitiveText = false;
YAHOO.Shortcuts.sensitivityType = [];
YAHOO.Shortcuts.doUlt = false;
YAHOO.Shortcuts.location = "us";
YAHOO.Shortcuts.document_id = 0;
YAHOO.Shortcuts.document_type = "";
YAHOO.Shortcuts.document_title = "Bug report: strtol conversion";
YAHOO.Shortcuts.document_publish_date = "";
YAHOO.Shortcuts.document_author = "daniel@zuster.org";
YAHOO.Shortcuts.document_url = "";
YAHOO.Shortcuts.document_tags = "";
YAHOO.Shortcuts.annotationSet = {

};
</script>
<style type="text/css"><!-- DIV {margin:0px;}--></style><link rel="stylesheet" href="http://us.js2.yimg.com/us.js.yimg.com/lib/lw/contextual_shortcuts_3.0.4.css" type="text/css" media="all"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi,<br><br>I believe I have found a bug in the current uclibc implementation<br>of strtol (and friends).<br><br>An example failing program is:<br>assert(strtol("+2``2`4", 0, 10) == 2);<br><br>The problem is that uclibc is treating the characters '`' as the digit 9. The bug <br>is in the vicinity of stdlib.c:561 (and 712), in the digit computation:<br><br>--<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; digit = (((Wuchar)(*str - '0')) &lt;= 9)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ? (*str - '0')<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : (((*str) &gt;= 'A')<br>&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ? (((0x20|(*str)) - 'a' + 10)) /* WARNING: assumes
 ascii. */<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; : 40);<br>--<br><br>I do not know what the preferred fix is, but I have verified that the following code at<br>least correctly computes digits for base 10.<br><br>--<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; digit = (((Wuchar)(*str - '0')) &lt;= 9)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ? (*str - '0')<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : (((0x20|(*str)) &gt;= 'A')<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ? (((0x20|(*str)) - 'a' + 10)) /* WARNING: assumes ascii. */<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; : 40);<br>
--<br><br>&nbsp;- Daniel<br><br>
</div></div><span id="lw_beacon_1208613767015"></span><div style="top: -400px; left: -400px; position: absolute;" class="module overlay yui-module yui-overlay" id="lwPreview"><div class="hd"></div><div class="bd"></div><div class="ft"></div></div></div></div></body></html>