diff --git a/scan/scan_int.c b/scan/scan_int.c index b881db2..c4e8a10 100644 --- a/scan/scan_int.c +++ b/scan/scan_int.c @@ -3,6 +3,6 @@ unsigned int scan_int(const char* src,int* dest) { long l; register int len=scan_long(src,&l); - *dest=l; + if (len) *dest=l; return len; } diff --git a/scan/scan_long.c b/scan/scan_long.c index 53aef1c..8f2148d 100644 --- a/scan/scan_long.c +++ b/scan/scan_long.c @@ -5,7 +5,8 @@ unsigned int scan_long(const char *src,long *dest) { register long int l; register unsigned char c; int neg; - tmp=src; l=0; neg=0; + int ok; + tmp=src; l=0; ok=neg=0; switch (*tmp) { case '-': neg=1; case '+': ++tmp; @@ -13,7 +14,8 @@ unsigned int scan_long(const char *src,long *dest) { while ((c=*tmp-'0')<10) { l=l*10+c; ++tmp; + ok=1; } - *dest=(neg?-l:l); + if (ok) *dest=(neg?-l:l); return tmp-src; } diff --git a/scan/scan_longlong.c b/scan/scan_longlong.c index 393d1b6..2d57328 100644 --- a/scan/scan_longlong.c +++ b/scan/scan_longlong.c @@ -6,7 +6,7 @@ unsigned int scan_longlong(const char* src,signed long long* dest) { char c=src[0]; o=c=='-' || c=='+'; if ((i=scan_ulonglong(src+o,&l))) { - *dest=c=='-'?-l:l; + if (i+o) *dest=c=='-'?-l:l; return i+o; } return 0; } diff --git a/scan/scan_uint.c b/scan/scan_uint.c index 33f8501..656bc33 100644 --- a/scan/scan_uint.c +++ b/scan/scan_uint.c @@ -24,7 +24,7 @@ unsigned int scan_uint(const char* src,unsigned int* dest) { l=n+c; ++tmp; } - *dest=l; + if (tmp-src) *dest=l; return tmp-src; } } diff --git a/scan/scan_ulong.c b/scan/scan_ulong.c index e11f564..5d38bc2 100644 --- a/scan/scan_ulong.c +++ b/scan/scan_ulong.c @@ -14,6 +14,6 @@ unsigned int scan_ulong(const char* src,unsigned long int* dest) { l=n+c; ++tmp; } - *dest=l; + if (tmp-src) *dest=l; return tmp-src; } diff --git a/scan/scan_ulonglong.c b/scan/scan_ulonglong.c index 6d53c58..3ef5ce5 100644 --- a/scan/scan_ulonglong.c +++ b/scan/scan_ulonglong.c @@ -14,6 +14,6 @@ unsigned int scan_ulonglong(const char *src,unsigned long long *dest) { l=n+c; ++tmp; } - *dest=l; + if (tmp-src) *dest=l; return tmp-src; } diff --git a/scan/scan_ushort.c b/scan/scan_ushort.c index 5fe76a3..483319b 100644 --- a/scan/scan_ushort.c +++ b/scan/scan_ushort.c @@ -24,7 +24,7 @@ unsigned int scan_ushort(const char* src,unsigned short* dest) { l=n+c; ++tmp; } - *dest=l; + if (tmp-src) *dest=l; return tmp-src; } }