[444] | 1 | /* |
---|
| 2 | FUNCTION |
---|
| 3 | <<atoi>>, <<atol>>---string to integer |
---|
| 4 | |
---|
| 5 | INDEX |
---|
| 6 | atoi |
---|
| 7 | INDEX |
---|
| 8 | atol |
---|
| 9 | INDEX |
---|
| 10 | _atoi_r |
---|
| 11 | INDEX |
---|
| 12 | _atol_r |
---|
| 13 | |
---|
| 14 | SYNOPSIS |
---|
| 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 | |
---|
| 21 | DESCRIPTION |
---|
| 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 | |
---|
| 31 | RETURNS |
---|
| 32 | The functions return the converted value, if any. If no conversion was |
---|
| 33 | made, <<0>> is returned. |
---|
| 34 | |
---|
| 35 | PORTABILITY |
---|
| 36 | <<atoi>>, <<atol>> are ANSI. |
---|
| 37 | |
---|
| 38 | No 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 |
---|
| 49 | int |
---|
| 50 | atoi (const char *s) |
---|
| 51 | { |
---|
| 52 | return (int) strtol (s, NULL, 10); |
---|
| 53 | } |
---|
| 54 | #endif /* !_REENT_ONLY */ |
---|
| 55 | |
---|
| 56 | int |
---|
| 57 | _atoi_r (struct _reent *ptr, |
---|
| 58 | const char *s) |
---|
| 59 | { |
---|
| 60 | return (int) _strtol_r (ptr, s, NULL, 10); |
---|
| 61 | } |
---|
| 62 | |
---|