Ejemplo n.º 1
0
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));
	}
Ejemplo n.º 2
0
Archivo: stdlib.c Proyecto: BigEd/Cores
long (atol)(const char *s)
{
	return ((long)_Stoul(s, NULL, 10));
}
Ejemplo n.º 3
0
Archivo: stdlib.c Proyecto: BigEd/Cores
int (atoi)(const char *s)
{
	return ((int)_Stoul(s, NULL, 10));
}
Ejemplo n.º 4
0
Archivo: ATOI.C Proyecto: Justme0/CLIB
int (atoi)(const char *s)
	{	/* convert string to int */
	return ((int)_Stoul(s, NULL, 10));
	}