mirror of /home/gitosis/repositories/libowfat.git
20 lines
409 B
C
20 lines
409 B
C
#include "scan.h"
|
|
|
|
static const unsigned long maxlong = ((unsigned long)-1)>>1;
|
|
|
|
size_t scan_longlong(const char* src,signed long long* dest) {
|
|
unsigned int i,o;
|
|
unsigned long long l;
|
|
char c=src[0];
|
|
int neg=c=='-';
|
|
o=c=='-' || c=='+';
|
|
if ((i=scan_ulonglong(src+o,&l))) {
|
|
if (i>0 && l>maxlong+neg) {
|
|
l/=10;
|
|
--i;
|
|
}
|
|
if (i+o) *dest=c=='-'?-l:l;
|
|
return i+o;
|
|
} return 0;
|
|
}
|