add long long scanning support
parent
72ba2ad6b5
commit
09e6dc97e3
@ -0,0 +1,12 @@
|
||||
#include "scan.h"
|
||||
|
||||
unsigned int scan_longlong(const char* src,signed long long* dest) {
|
||||
unsigned int i,o;
|
||||
unsigned long long l;
|
||||
char c=src[0];
|
||||
o=c=='-' || c=='+';
|
||||
if ((i=scan_ulonglong(src+o,&l))) {
|
||||
*dest=c=='-'?-l:l;
|
||||
return i+o;
|
||||
} return 0;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#include "scan.h"
|
||||
|
||||
unsigned int scan_ulonglong(const char *src,unsigned long long *dest) {
|
||||
register const char *tmp=src;
|
||||
register unsigned long long l=0;
|
||||
register unsigned char c;
|
||||
while ((c=*tmp-'0')<10) {
|
||||
unsigned long long m=l;
|
||||
l=l*10+c;
|
||||
if ((l>>3) < m) break;
|
||||
++tmp;
|
||||
}
|
||||
*dest=l;
|
||||
return tmp-src;
|
||||
}
|
Loading…
Reference in New Issue