纳瓦特官网提高库包文件编译提示警告信息,查看函数原型发现存在问题,待官网确认
uint32
strtoul (char *str, char **ptr, int base)
{
unsigned long rvalue;
int c, err, neg;
char *endp;
char *startp;
rvalue = 0; err = 0; neg = 0;
/* Check for invalid arguments */
if ((str == NULL) || (base < 0) || (base == 1) || (base > 36))
{
if (ptr != NULL)
{
*ptr = str;
}
return 0;
}
/* Skip leading white spaces */
for (startp = str; isspace(*startp); ++startp)
;
/* Check for notations */
switch (startp[0])
{
case '0':
if ((startp[1] == 'x') || (startp[1] == 'X'))
{
if ((base == 0) || (base == 16))
{
base = 16;
startp = &startp[2];
}
}
break;
case '-':
neg = 1;
startp = &startp[1];
break;
default:
break;
}
if (base == 0)
base = 10;
/* Check for invalid chars in str */
for ( endp = startp; (c = *endp) != '\0'; ++endp)
{
/* Check for 0..9,Aa-Zz */
if (!isalnum(c))
{
err = 1;
break;
}
/* Convert char to num in 0..36 */
if (isdigit(c))
{
c = c - '0';
}
else
{
if (isupper(c))
{
c = c - 'A' + 10;
}
else
{
c = c - 'a' + 10;
}
}
/* check c against base */
if (c >= base)
{
err = 1;
break;
}
if (neg)
{
rvalue = (rvalue * base) - c;
}
else
{
rvalue = (rvalue * base) + c;
}
}
/* Upon exit, endp points to the character at which valid info */
/* STOPS. No chars including and beyond endp are used. */
if (ptr != NULL)
*ptr = endp;
if (err)
{
if (ptr != NULL)
*ptr = str;
return 0;
}
else
{
return rvalue;
}
}
以上红字部分,原来是没有的,后来编译提示警告信息,更改了过来;
希望官网确认下我指出的是否是明显的BUG问题。
|