]> diplodocus.org Git - nmh/blob - sbr/m_atoi.c
Changed scan to always pass the folder argument. This is in line
[nmh] / sbr / m_atoi.c
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$
8 *
9 * This code is Copyright (c) 2002, by the authors of nmh. See the
10 * COPYRIGHT file in the root directory of the nmh distribution for
11 * complete copyright information.
12 */
13
14 #include <h/mh.h>
15
16
17 int
18 m_atoi (char *str)
19 {
20 int i;
21 char *cp;
22
23 for (i = 0, cp = str; *cp; cp++) {
24 #ifdef LOCALE
25 if (!isdigit(*cp))
26 #else
27 if (*cp < '0' || *cp > '9')
28 #endif
29 return 0;
30
31 i *= 10;
32 i += (*cp - '0');
33 }
34
35 return i;
36 }