scan_ulong.c
author tomas@localhost
Thu, 01 Nov 2007 14:46:11 +0100
changeset 0 c045670f36e9
permissions -rw-r--r--
Imported queue-fix-1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     1
#include "scan.h"
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     2
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     3
unsigned int scan_ulong(s,u) register char *s; register unsigned long *u;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     4
{
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     5
  register unsigned int pos; register unsigned long result;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     6
  register unsigned long c;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     7
  pos = 0; result = 0;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     8
  while ((c = (unsigned long) (unsigned char) (s[pos] - '0')) < 10)
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     9
    { result = result * 10 + c; ++pos; }
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    10
  *u = result; return pos;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    11
}