示例#1
0
文件: STRTOL.C 项目: Justme0/CLIB
long (strtol)(const char *s, char **endptr, int base)
	{	/* convert string to long, with checking */
	const char *sc;
	char *se, sign;
	unsigned long x;

	if (endptr == NULL)
		endptr = &se;
	for (sc = s; isspace(*sc); ++sc)
		;
	sign = *sc == '-' || *sc == '+' ? *sc++ : '+';
	x = _Stoul(sc, endptr, base);
	if (sc == *endptr)
		*endptr = (char *)s;
	if (s == *endptr && x != 0 || sign == '+' && LONG_MAX < x
		|| sign == '-' && -(unsigned long)LONG_MIN < x)
		{	/* overflow */
		errno = ERANGE;
		return (sign == '-' ? LONG_MIN : LONG_MAX);
		}
	else
		return ((long)(sign == '-' ? -x : x));
	}
示例#2
0
文件: stdlib.c 项目: BigEd/Cores
long (atol)(const char *s)
{
	return ((long)_Stoul(s, NULL, 10));
}
示例#3
0
文件: stdlib.c 项目: BigEd/Cores
int (atoi)(const char *s)
{
	return ((int)_Stoul(s, NULL, 10));
}
示例#4
0
文件: ATOI.C 项目: Justme0/CLIB
int (atoi)(const char *s)
	{	/* convert string to int */
	return ((int)_Stoul(s, NULL, 10));
	}