only write dest if we actually parsed something
This commit is contained in:
parent
5b599cb67d
commit
85bfbeb420
@ -3,6 +3,6 @@
|
|||||||
unsigned int scan_int(const char* src,int* dest) {
|
unsigned int scan_int(const char* src,int* dest) {
|
||||||
long l;
|
long l;
|
||||||
register int len=scan_long(src,&l);
|
register int len=scan_long(src,&l);
|
||||||
*dest=l;
|
if (len) *dest=l;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ unsigned int scan_long(const char *src,long *dest) {
|
|||||||
register long int l;
|
register long int l;
|
||||||
register unsigned char c;
|
register unsigned char c;
|
||||||
int neg;
|
int neg;
|
||||||
tmp=src; l=0; neg=0;
|
int ok;
|
||||||
|
tmp=src; l=0; ok=neg=0;
|
||||||
switch (*tmp) {
|
switch (*tmp) {
|
||||||
case '-': neg=1;
|
case '-': neg=1;
|
||||||
case '+': ++tmp;
|
case '+': ++tmp;
|
||||||
@ -13,7 +14,8 @@ unsigned int scan_long(const char *src,long *dest) {
|
|||||||
while ((c=*tmp-'0')<10) {
|
while ((c=*tmp-'0')<10) {
|
||||||
l=l*10+c;
|
l=l*10+c;
|
||||||
++tmp;
|
++tmp;
|
||||||
|
ok=1;
|
||||||
}
|
}
|
||||||
*dest=(neg?-l:l);
|
if (ok) *dest=(neg?-l:l);
|
||||||
return tmp-src;
|
return tmp-src;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ unsigned int scan_longlong(const char* src,signed long long* dest) {
|
|||||||
char c=src[0];
|
char c=src[0];
|
||||||
o=c=='-' || c=='+';
|
o=c=='-' || c=='+';
|
||||||
if ((i=scan_ulonglong(src+o,&l))) {
|
if ((i=scan_ulonglong(src+o,&l))) {
|
||||||
*dest=c=='-'?-l:l;
|
if (i+o) *dest=c=='-'?-l:l;
|
||||||
return i+o;
|
return i+o;
|
||||||
} return 0;
|
} return 0;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ unsigned int scan_uint(const char* src,unsigned int* dest) {
|
|||||||
l=n+c;
|
l=n+c;
|
||||||
++tmp;
|
++tmp;
|
||||||
}
|
}
|
||||||
*dest=l;
|
if (tmp-src) *dest=l;
|
||||||
return tmp-src;
|
return tmp-src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ unsigned int scan_ulong(const char* src,unsigned long int* dest) {
|
|||||||
l=n+c;
|
l=n+c;
|
||||||
++tmp;
|
++tmp;
|
||||||
}
|
}
|
||||||
*dest=l;
|
if (tmp-src) *dest=l;
|
||||||
return tmp-src;
|
return tmp-src;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,6 @@ unsigned int scan_ulonglong(const char *src,unsigned long long *dest) {
|
|||||||
l=n+c;
|
l=n+c;
|
||||||
++tmp;
|
++tmp;
|
||||||
}
|
}
|
||||||
*dest=l;
|
if (tmp-src) *dest=l;
|
||||||
return tmp-src;
|
return tmp-src;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ unsigned int scan_ushort(const char* src,unsigned short* dest) {
|
|||||||
l=n+c;
|
l=n+c;
|
||||||
++tmp;
|
++tmp;
|
||||||
}
|
}
|
||||||
*dest=l;
|
if (tmp-src) *dest=l;
|
||||||
return tmp-src;
|
return tmp-src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user