EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: tool_lib.c -- next attempt
From: Eric Norum <[email protected]>
To: Andrew Johnson <[email protected]>
Cc: EPICS core-talk <[email protected]>
Date: Wed, 8 May 2013 12:37:24 -0700
Im fairly confident in the behaviour on both signed and unsigned char architectures since the base 10 code is pretty much the same as it was before (assign to native char type, then print).   As Andrew mentions, I have no (char)==(unsigned char) hardware on which to confirm this though.

On May 8, 2013, at 12:32 PM, Andrew Johnson <[email protected]> wrote:

Hi Ralph,

Any comments or objections?  I haven't tried this myself yet.  We do need to
confirm that any change doesn't modify the original behavior on both kinds of
architectures where char is signed or unsigned; I suspect Eric has only tried
one type of CPU (x86).

- Andrew
--
It is difficult to get a man to understand something, when his salary
depends upon his not understanding it. -- Upton Sinclair

From: Eric Norum <[email protected]>
Subject: tool_lib.c -- next attempt
Date: May 8, 2013 11:53:06 AM PDT
To: Andrew Johnson <[email protected]>


Seems to to what it should.  I think that this maintains backward compatibility.

diff -b  -U7 tool_lib.c.orig tool_lib.c
--- tool_lib.c.orig 2013-05-08 11:15:28.000000000 -0700
+++ tool_lib.c 2013-05-08 11:51:47.000000000 -0700
@@ -102,15 +102,14 @@
 *
 **************************************************************************-*/

char *val2str (const void *v, unsigned type, int index)
{
#define STR 500
    static char str[STR];
-    char ch;
    void *val_ptr;
    unsigned base_type;
    dbr_long_t val_long;

    if (!dbr_type_is_valid(type)) {
        strcpy (str, "*** invalid type");
        return str;
@@ -146,16 +145,21 @@
            val_long = ((dbr_double_t*) val_ptr)[index] + 0.5;
          else
            val_long = ((dbr_double_t*) val_ptr)[index] - 0.5;
          sprint_long(str, val_long, outTypeF);
        }
        break;
    case DBR_CHAR:
-        ch = ((dbr_char_t*) val_ptr)[index];
-        sprintf(str, "%d", ch);
+        if (outTypeI == dec) {
+            char ch = ((dbr_char_t*) val_ptr)[index];
+            sprint_long(str, ch, outTypeI);
+        }
+        else {
+            sprint_long(str, ((dbr_char_t*) val_ptr)[index], outTypeI);
+        }
        break;
    case DBR_INT:
        sprint_long(str, ((dbr_int_t*) val_ptr)[index], outTypeI);
        break;
    case DBR_LONG:
        sprint_long(str, ((dbr_long_t*) val_ptr)[index], outTypeI);
        break;

--
Eric Norum
[email protected]




-- 
Eric Norum
[email protected]





References:
Fwd: tool_lib.c -- next attempt Andrew Johnson

Navigate by Date:
Prev: Fwd: tool_lib.c -- next attempt Andrew Johnson
Next: [Merge] lp:~epics-core/epics-base/devlib2mmio into lp:epics-base mdavidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Fwd: tool_lib.c -- next attempt Andrew Johnson
Next: [Merge] lp:~epics-core/epics-base/devlib2mmio into lp:epics-base mdavidsaver
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  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 ·