Subject: |
Re: Problem with using strings to access enum indices on Windows |
From: |
Andrew Johnson <[email protected]> |
To: |
[email protected] |
Date: |
Mon, 24 Sep 2012 11:27:11 -0500 |
Hi Lewis,
On 2012-09-24 J. Lewis Muir wrote:
> 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).
I would prefer to avoid ifdefs in this situation. I added a set of APIs to
epicsStdlib.h in the R3.15 tree for doing string to integer conversions. They
call strtol() or strtoul() and check for numeric overflow of the various
different type sizes, allow you to say whether you're looking for a trailing
string (units say) or not, and return a status/error code. I have a branch
which uses this API for all string conversions in dbConvert.c and dbFastConv.c
but I haven't merged it because it changes the conversion behavior of the IOC
in subtle ways. For example numeric overflow used to cause value truncation,
but with this API the conversion fails instead.
One of Marty's regression tests for Base runs a series of conversions between
all the different types using both DB and CA links and outputs the results as
a large file. The actual output has always varied between targets, OSs and
versions of Base, and I have never completely managed to explain all the
differences to my own satisfaction. The above branch definitely changes the
output from this test, although I believe it makes the different targets & OSs
behave more similarly than they used to.
I would be interested in other people's views on conversion behavior by the
IOC (what it should do, not so much how it should be implemented).
- Andrew
--
Never interrupt your enemy when he is making a mistake.
-- Napoleon Bonaparte
- 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
- Re: Problem with using strings to access enum indices on Windows J. Lewis Muir
- Navigate by Date:
- Prev:
Re: DHCP/BOOTP configuration for EPICS with RTEMS Eric Norum
- Next:
Re: DHCP/BOOTP configuration for EPICS with RTEMS Bruno Seiva Martins
- 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 J. Lewis Muir
- 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
|