You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
373 B
C

24 years ago
#include "scan.h"
unsigned int scan_long(const char *src,long *dest) {
register const char *tmp;
register long int l;
24 years ago
register unsigned char c;
int neg;
int ok;
tmp=src; l=0; ok=neg=0;
24 years ago
switch (*tmp) {
case '-': neg=1;
case '+': ++tmp;
}
while ((c=*tmp-'0')<10) {
l=l*10+c;
++tmp;
ok=1;
24 years ago
}
if (ok) *dest=(neg?-l:l);
24 years ago
return tmp-src;
}