
/*
 * m_atoi.c -- parse a string representation of a message number
 *
 * $Id$
 */

#include <h/mh.h>


int
m_atoi (char *str)
{
    int i;
    char  *cp;

    i = 0;
    cp = str;
#ifdef LOCALE
    while (isdigit(*cp)) {
	i *= 10;
	i += *cp++ - '0';
    }
#else
    while (*cp) {
	if (*cp < '0' || *cp > '9')
	    return 0;
	i *= 10;
	i += *cp++ - '0';
    }
#endif

    return i;
}
