[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: [PATCH] [Msvcrt]: fixing errno handling in strtol and strtoul
From:       David Laight <david () l8s ! co ! uk>
Date:       2009-08-31 15:57:27
Message-ID: 20090831155727.GB6353 () snowdrop ! l8s ! co ! uk
[Download RAW message or body]

On Mon, Aug 31, 2009 at 12:03:11PM +0200, Alexandre Julliard wrote:
> Eric Pouech <eric.pouech@orange.fr> writes:
> 
> > @@ -250,3 +250,25 @@ int CDECL __STRINGTOLD( MSVCRT__LDOUBLE *value, char **endptr, const char *str,
> >  #endif
> >      return 0;
> >  }
> > +
> > +/******************************************************************
> > + *		strtol (MSVCRT.@)
> > + */
> > +long int MSVCRT_strtol(const char* nptr, char** end, int base)
> > +{
> > +    /* wrapper to forward libc error code to msvcrt's error codes */
> > +    long ret = strtol(nptr, end, base);
> > +    msvcrt_set_unix_errno();
> > +    return ret;
> > +}
> 
> You can't simply use long here, you need to handle the difference in the
> size of long between Win32 and Unix.

You also need to an 'errno = 0' before the strtol() call.
strtol() will only change errno if there is a numeric overflow.

In the overflow cases the return value will be LONG_MIN or LONG_MAX and
errno is set to ERANGE.  No other errno values should appear.

I thought that the only 'size' difference is that 64bit windows has a
32bit long ?
So values outside 32bits need truncating and ERANGE set ??

	David

-- 
David Laight: david@l8s.co.uk


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic