On 9/24/12 10:10 AM, Mark Rivers wrote:
> One solution would be the following in dbFastLinkConv.c.
>
> #ifdef _WIN32
> #define UNSIGNED_FORMAT " %u%n"
> #else
> #define UNSIGNED_FORMAT " %u %n"
> #endif
>
> nargs = sscanf(from,UNSIGNED_FORMAT,&ind,&nchars);
> if(nargs==1 && nchars==strlen(from) && ind<nchoices) {
> *pfield = ind;
> return(0);
> }
>
> This would preserve the current behavior on all platforms except _WIN32. It would allow _WIN32 to correctly parse all strings except those with trailing whitespace, which is much better than the current situation where it fails for all strings that do NOT have trailing whitespace.
I think it's nicer if ifdefs can be avoided. Another approach
might be to try using the "%c" format specifier to match just
one char. Maybe it works correctly on Windows when preceded by
a space in the format string?
Or, there's also strtoul. This will allow leading white space,
but you'd have to check the end pointer to allow trailing white
space (since with trailing white space it would not point to a
NUL char).
Lewis
- Replies:
- Re: Problem with using strings to access enum indices on Windows Andrew Johnson
- References:
- Problem with using strings to access enum indices on Windows Mark Rivers
- RE: Problem with using strings to access enum indices on Windows Mark Rivers
- Navigate by Date:
- Prev:
Re: DHCP/BOOTP configuration for EPICS with RTEMS Bruno Seiva Martins
- Next:
Re: DHCP/BOOTP configuration for EPICS with RTEMS Eric Norum
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Problem with using strings to access enum indices on Windows Eric Norum
- Next:
Re: Problem with using strings to access enum indices on Windows Andrew Johnson
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|