g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
<== Date ==> <== Thread ==>

Subject: Fwd: tool_lib.c -- next attempt
From: Andrew Johnson <anj@aps.anl.gov>
To: Ralph Lange <Ralph.Lange@gmx.de>, "EPICS core-talk" <core-talk@aps.anl.gov>
Date: Wed, 8 May 2013 14:32:36 -0500
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
--- Begin Message ---
Subject: tool_lib.c -- next attempt
From: Eric Norum <wenorum@lbl.gov>
To: Andrew Johnson <anj@aps.anl.gov>
Date: Wed, 8 May 2013 11:53:06 -0700
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
wenorum@lbl.gov


--- End Message ---

Replies:
Re: tool_lib.c -- next attempt Eric Norum

Navigate by Date:
Prev: EPICS V4 - SvrBrowse and PvBrowse Carsten Winkler
Next: Re: tool_lib.c -- next attempt Eric Norum
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
Navigate by Thread:
Prev: EPICS V4 - SvrBrowse and PvBrowse Carsten Winkler
Next: Re: tool_lib.c -- next attempt Eric Norum
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·