EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Problem with using strings to access enum indices on Windows
From: Eric Norum <[email protected]>
To: Mark Rivers <[email protected]>
Cc: EPICS tech talk <[email protected]>
Date: Mon, 24 Sep 2012 08:27:43 -0700
Sounds reasonable, but rather than a conditional, would it be better to put the macro into one of the existing os-specific headers, say, osdStrtod.h?

#define DB_CVT_ST_E_FORMAT	……..

On Sep 24, 2012, at 8:10 AM, Mark Rivers <[email protected]> wrote:

> Hi Dirk,
> 
> You are right, the blank should match 0 whitespace characters.
> 
> In the limited tests I have done the problem appears to be confined to %n.  For example in my Windows test output this worked:
> 
> String=' 123' format=' %u%n': ui=123, strlen(string)=4, nchars=4
> 
> So there is a leading blank before the %u format specifier, and no leading whitespace in the input string.  But it worked, so Windows does allow 0 whitespace characters in this case.
> 
> Note that in my original post in talking about spec I said:
> epics_put(PV, "1") works fine on Linux, vxWorks, etc. but fails on Windows
> 
> In that case it is obvious that spec should be sending the index as a string.  But what also fails on Windows is this:
> epics_put(PV, 1) works fine on Linux, vxWorks, etc. but fails on Windows
> 
> In this case it is not obvious that spec is sending 1 as a string, but in fact it does, because it sends everything as a string.
> 
> Note that Gerry Swislow said he will change spec version 6 to do the following:
> 
> epics_put(PV, "1")  will use DBF_STRING
> epics_put(PV, 1) will use DBF_ENUM
> 
> That will also fix the problem.  But I think we should consider fixing EPICS base as well.
> 
> 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.
> 
> Mark

-- 
Eric Norum
[email protected]



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 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  <20122013  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 Mark Rivers
Next: Re: Problem with using strings to access enum indices on Windows J. Lewis Muir
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·