Browse Source

only write dest if we actually parsed something

master
Felix von Leitner 18 years ago
parent
commit
ec9299ff57
  1. 2
      scan/scan_int.c
  2. 6
      scan/scan_long.c
  3. 2
      scan/scan_longlong.c
  4. 2
      scan/scan_uint.c
  5. 2
      scan/scan_ulong.c
  6. 2
      scan/scan_ulonglong.c
  7. 2
      scan/scan_ushort.c

2
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;
}

6
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;
}

2
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;
}

2
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;
}
}

2
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;
}

2
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;
}

2
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;
}
}

Loading…
Cancel
Save