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.

20 lines
432 B

#include "scan.h"
static const unsigned long maxlong = ((unsigned long)-1)>>1;
size_t scan_longlong(const char* src,signed long long* dest) {
size_t i,o;
unsigned long long l;
char c=src[0];
unsigned int neg=c=='-';
o=c=='-' || c=='+';
if ((i=scan_ulonglong(src+o,&l))) {
if (i>0 && l>maxlong+neg) {
if (i+o) *dest=(signed long long)(c=='-'?-l:l);
return i+o;
} return 0;