source: trunk/libs/newlib/src/newlib/libc/stdlib/atoi.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/*
2FUNCTION
3   <<atoi>>, <<atol>>---string to integer
4
5INDEX
6        atoi
7INDEX
8        atol
9INDEX
10        _atoi_r
11INDEX
12        _atol_r
13
14SYNOPSIS
15        #include <stdlib.h>
16        int atoi(const char *<[s]>);
17        long atol(const char *<[s]>);
18        int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>);
19        long _atol_r(struct _reent *<[ptr]>, const char *<[s]>);
20
21DESCRIPTION
22   <<atoi>> converts the initial portion of a string to an <<int>>.
23   <<atol>> converts the initial portion of a string to a <<long>>.
24
25   <<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>>
26   <<atol(s)>> is implemented as <<strtol(s, NULL, 10).>>
27
28   <<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and
29   <<atol>> respectively, passing the reentrancy struct pointer.
30
31RETURNS
32   The functions return the converted value, if any. If no conversion was
33   made, <<0>> is returned.
34
35PORTABILITY
36<<atoi>>, <<atol>> are ANSI.
37
38No supporting OS subroutines are required.
39*/
40
41/*
42 * Andy Wilson, 2-Oct-89.
43 */
44
45#include <stdlib.h>
46#include <_ansi.h>
47
48#ifndef _REENT_ONLY
49int
50atoi (const char *s)
51{
52  return (int) strtol (s, NULL, 10);
53}
54#endif /* !_REENT_ONLY */
55
56int
57_atoi_r (struct _reent *ptr,
58        const char *s)
59{
60  return (int) _strtol_r (ptr, s, NULL, 10);
61}
62
Note: See TracBrowser for help on using the repository browser.