source: trunk/third/nmh/sbr/m_atoi.c @ 12455

Revision 12455, 530 bytes checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * m_atoi.c -- Parse a string representation of a message number, and
4 *          -- return the numeric value of the message.  If the string
5 *          -- contains any non-digit characters, then return 0.
6 *
7 * $Id: m_atoi.c,v 1.1.1.1 1999-02-07 18:14:09 danw Exp $
8 */
9
10#include <h/mh.h>
11
12
13int
14m_atoi (char *str)
15{
16    int i;
17    char *cp;
18
19    for (i = 0, cp = str; *cp; cp++) {
20#ifdef LOCALE
21        if (!isdigit(*cp))
22#else
23        if (*cp < '0' || *cp > '9')
24#endif
25            return 0;
26
27        i *= 10;
28        i += (*cp - '0');
29    }
30
31    return i;
32}
Note: See TracBrowser for help on using the repository browser.