aboutsummaryrefslogtreecommitdiff
path: root/djb/scan_number.h
blob: 17e15869854377849732e5052b2b5b712f187abf (plain)
1
2
3
4
5
6
7
8
9
#define SCAN_NUMBER_DEFINE(name, type, base) \
unsigned int name(const char *s, type *u) {\
  unsigned int pos;\
  type result, c;\
  pos = 0; result = 0;\
  while ((c = (type) (unsigned char) (s[pos] - '0')) < base)\
    { result = result * base + c; ++pos; }\
  *u = result; return pos;\
}