Fix the c200 manual which was broken by yesterday's button action macros in the radio...
[Rockbox.git] / firmware / common / atoi.c
blob59887ec9fa563588da09fe594cea32aae2869321
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Gary Czvitkovicz
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "ctype.h"
22 int atoi (const char *str)
24 int value = 0;
25 int sign = 1;
27 while (isspace(*str))
29 str++;
32 if ('-' == *str)
34 sign = -1;
35 str++;
37 else if ('+' == *str)
39 str++;
42 while ('0' == *str)
44 str++;
47 while (isdigit(*str))
49 value = (value * 10) + (*str - '0');
50 str++;
53 return value * sign;