[perl5] Clear errno before calls to strtol(), strtoul(), strtoll()

and strtoull() which we check errno after to avoid seeing a junk
value of errno if there isn't an error in the call.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10013 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2007-10-19 03:35:49 +00:00
commit 87e64a237b
2 changed files with 17 additions and 4 deletions

View file

@ -1,6 +1,11 @@
Version 1.3.32 (in progress)
============================
10/19/2007: olly
[perl5] Clear errno before calls to strtol(), strtoul(), strtoll()
and strtoull() which we check errno after to avoid seeing a junk
value of errno if there isn't an error in the call.
10/16/2007: wsfulton
Deprecate %attribute_ref and replace with %attributeref. There is just an argument
order change in order to maintain consistency with %attribute, from:

View file

@ -63,7 +63,9 @@ SWIG_AsVal_dec(long)(SV *obj, long* val)
const char *nptr = SvPV(obj, PL_na);
if (nptr) {
char *endptr;
long v = strtol(nptr, &endptr,0);
long v;
errno = 0;
v = strtol(nptr, &endptr,0);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;
@ -121,7 +123,9 @@ SWIG_AsVal_dec(unsigned long)(SV *obj, unsigned long *val)
const char *nptr = SvPV(obj, PL_na);
if (nptr) {
char *endptr;
unsigned long v = strtoul(nptr, &endptr,0);
unsigned long v;
errno = 0;
v = strtoul(nptr, &endptr,0);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;
@ -182,7 +186,9 @@ SWIG_AsVal_dec(long long)(SV *obj, long long *val)
const char *nptr = SvPV(obj, PL_na);
if (nptr) {
char *endptr;
long long v = strtoll(nptr, &endptr,0);
long long v;
errno = 0;
v = strtoll(nptr, &endptr,0);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;
@ -252,7 +258,9 @@ SWIG_AsVal_dec(unsigned long long)(SV *obj, unsigned long long *val)
const char *nptr = SvPV(obj, PL_na);
if (nptr) {
char *endptr;
unsigned long long v = strtoull(nptr, &endptr,0);
unsigned long long v;
errno = 0;
v = strtoull(nptr, &endptr,0);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;