get rid of undefined behavior regarding -INT_MAX

master
leitner 1 year ago
parent 90529e9952
commit cee447066f

@ -38,7 +38,7 @@ size_t scan_int(const char* src,int* dest) {
ok=1; ok=1;
} }
if (!ok) return 0; if (!ok) return 0;
*dest=(neg?-l:l); *dest=(neg?-(unsigned int)l:l);
return (size_t)(tmp-src); return (size_t)(tmp-src);
} }

@ -39,6 +39,6 @@ size_t scan_longn(const char *src,size_t len,long *dest) {
ok=1; ok=1;
} }
if (!ok) return 0; if (!ok) return 0;
*dest=(neg?-l:l); *dest=(neg?-(unsigned long int)l:l);
return (size_t)(tmp-src); return (size_t)(tmp-src);
} }

Loading…
Cancel
Save