Subversion Repositories Kolibri OS

Rev

Rev 8793 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <ctype.h>
  2. #include <stdlib.h>
  3.  
  4. long atol(const char* s)
  5. {
  6.     long n = 0;
  7.     int neg = 0;
  8.     while (isspace(*s))
  9.         s++;
  10.     switch (*s) {
  11.     case '-':
  12.         neg = 1;
  13.     case '+':
  14.         s++;
  15.     }
  16.     /* Compute n as a negative number to avoid overflow on LONG_MIN */
  17.     while (isdigit(*s))
  18.         n = 10 * n - (*s++ - '0');
  19.     return neg ? n : -n;
  20. }