Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  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. ANSI_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. TRAD_SYNOPSIS
  22.         #include <stdlib.h>
  23.        int atoi(<[s]>)
  24.        char *<[s]>;
  25.  
  26.        long atol(<[s]>)
  27.        char *<[s]>;
  28.  
  29.        int _atoi_r(<[ptr]>, <[s]>)
  30.        struct _reent *<[ptr]>;
  31.        char *<[s]>;
  32.  
  33.        long _atol_r(<[ptr]>, <[s]>)
  34.        struct _reent *<[ptr]>;
  35.        char *<[s]>;
  36.  
  37.  
  38. DESCRIPTION
  39.    <<atoi>> converts the initial portion of a string to an <<int>>.
  40.    <<atol>> converts the initial portion of a string to a <<long>>.
  41.  
  42.    <<atoi(s)>> is implemented as <<(int)strtol(s, NULL, 10).>>
  43.    <<atol(s)>> is implemented as <<strtol(s, NULL, 10).>>
  44.  
  45.    <<_atoi_r>> and <<_atol_r>> are reentrant versions of <<atoi>> and
  46.    <<atol>> respectively, passing the reentrancy struct pointer.
  47.  
  48. RETURNS
  49.    The functions return the converted value, if any. If no conversion was
  50.    made, <<0>> is returned.
  51.  
  52. PORTABILITY
  53. <<atoi>>, <<atol>> are ANSI.
  54.  
  55. No supporting OS subroutines are required.
  56. */
  57.  
  58. /*
  59.  * Andy Wilson, 2-Oct-89.
  60.  */
  61.  
  62. #include <stdlib.h>
  63. #include <_ansi.h>
  64.  
  65. #ifndef _REENT_ONLY
  66. int
  67. _DEFUN (atoi, (s),
  68.         _CONST char *s)
  69. {
  70.   return (int) strtol (s, NULL, 10);
  71. }
  72. #endif /* !_REENT_ONLY */
  73.  
  74. int
  75. _DEFUN (_atoi_r, (s),
  76.         struct _reent *ptr _AND
  77.         _CONST char *s)
  78. {
  79.   return (int) _strtol_r (ptr, s, NULL, 10);
  80. }
  81.  
  82.