File: scan_number.h

package info (click to toggle)
ngetty 1.0-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 304 kB
  • ctags: 207
  • sloc: ansic: 1,503; makefile: 236; sh: 109; asm: 100
file content (9 lines) | stat: -rw-r--r-- 292 bytes parent folder | download | duplicates (2)
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;\
}