]> diplodocus.org Git - nmh/blob - sbr/atooi.c
Fix invalid pointer arithmetic.
[nmh] / sbr / atooi.c
1 /* atooi.c -- octal version of atoi()
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include <h/mh.h>
9
10
11 int
12 atooi(char *cp)
13 {
14 int i, base;
15
16 i = 0;
17 base = 8;
18 while (*cp >= '0' && *cp <= '7') {
19 i *= base;
20 i += *cp++ - '0';
21 }
22
23 return i;
24 }