Public feed #381119

Something

public text v1 · immutable
Raw Edit
·published 2007-03-04 17:12 UTC
rendered paste body
unsigned int atoui(char *txt)
{
	unsigned int	retval = 0;
	unsigned int	lastval = 0;
	int pos = 0;

	while (txt[pos] != 0)
	{
		if (!isdigit(txt[pos]))
			return 0;

		retval *= 10;
		retval += txt[pos] - '0';

		if (retval < lastval)
			return 0;

		lastval = retval;
		pos++;
	}

	return retval;
}