[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-182-ga372637)



The branch, master has been updated
       via  a37263740000929363492726a069d92b161ab64c (commit)
      from  b47b0d1276a9535e3a66e4f8535f6c552849490f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/src/s_color.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)


=================
 Commit Messages
=================

commit a37263740000929363492726a069d92b161ab64c
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 14 00:37:54 2009 +0000

    libgeda: Make colormap hex codec functions more portable.
    
    The 'hh' length modifier was added in "The Open Group Base
    Specifications Issue 6". (IEEE Std 1003.1, 2004 Edition).
    
    Testing on wine's implementation of msvcrt.dll has shown
    that this modifier isn't implemented, leading to memory
    corruption / misread colour maps.
    
    Commit message ammended by Peter Clifton.

:100644 100644 2fbb6a0... 099d2fc... M	libgeda/src/s_color.c

=========
 Changes
=========

commit a37263740000929363492726a069d92b161ab64c
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 14 00:37:54 2009 +0000

    libgeda: Make colormap hex codec functions more portable.
    
    The 'hh' length modifier was added in "The Open Group Base
    Specifications Issue 6". (IEEE Std 1003.1, 2004 Edition).
    
    Testing on wine's implementation of msvcrt.dll has shown
    that this modifier isn't implemented, leading to memory
    corruption / misread colour maps.
    
    Commit message ammended by Peter Clifton.

diff --git a/libgeda/src/s_color.c b/libgeda/src/s_color.c
index 2fbb6a0..099d2fc 100644
--- a/libgeda/src/s_color.c
+++ b/libgeda/src/s_color.c
@@ -135,7 +135,7 @@ gboolean
 s_color_rgba_decode (const gchar *rgba,
                      guint8 *r, guint8 *g, guint8 *b, guint8 *a)
 {
-  gint len, i;
+  gint len, i, ri, gi, bi, ai;
   gchar c;
 
   /* Default to solid white */
@@ -156,14 +156,16 @@ s_color_rgba_decode (const gchar *rgba,
   }
 
   /* Use sscanf to extract values */
-  c = sscanf (rgba + 1, "%2hhx%2hhx%2hhx", r, g, b);
+  c = sscanf (rgba + 1, "%2x%2x%2x", &ri, &gi, &bi);
   if (c != 3)
     return FALSE;
+  *r = (guint8) ri; *g = (guint8) gi; *b = (guint8) bi;
 
   if (len == 9) {
-    c = sscanf (rgba + 7, "%2hhx", a);
+    c = sscanf (rgba + 7, "%2x", &ai);
     if (c != 1)
       return FALSE;
+    *a = (guint8) ai;
   }
 
   return TRUE;
@@ -184,9 +186,11 @@ gchar *
 s_color_rgba_encode (guint8 r, guint8 g, guint8 b, guint8 a)
 {
   if (a < 0xff)
-    return g_strdup_printf("#%02hhx%02hhx%02hhx%02hhx", r, g, b, a);
+    return g_strdup_printf("#%02x%02x%02x%02x",
+                           (gint) r, (gint) g, (gint) b, (gint) a);
   else
-    return g_strdup_printf("#%02hhx%02hhx%02hhx", r, g, b);
+    return g_strdup_printf("#%02x%02x%02x",
+                           (gint) r, (gint) g, (gint) b);
 }
 
 /*! \todo Finish function documentation!!!




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs