wide chars should better be unsigned
[rrdtool.git] / src / rrd_gfx.c
index a241fc2..f4c04ef 100644 (file)
@@ -7,9 +7,9 @@
 /* #define DEBUG */
 
 #ifdef DEBUG
-# define DPRINTF(x,...)  fprintf(stderr, x, ## __VA_ARGS__);
+# define DPRINTF(...)  fprintf(stderr, __VA_ARGS__);
 #else
-# define DPRINTF(x,...)
+# define DPRINTF(...)
 #endif
 #include "rrd_tool.h"
 #include <png.h>
@@ -386,7 +386,11 @@ gfx_string gfx_string_create(gfx_canvas_t *canvas, FT_Face face,const char *text
   cstr = malloc(sizeof(wchar_t) * clen); /* yes we are allocating probably too much here, I know */
   string->count=mbstowcs(cstr,text,clen);
   if ( string->count == -1){
-       string->count=mbstowcs(cstr,"Enc-Err",6);
+  /* conversion did not work, so lets fall back to just use what we got */
+       string->count=clen-1;
+        for(n=0;text[n] != '\0';n++){
+            cstr[n]=(unsigned char)text[n];
+        }
   }
 #else
   char         *cstr = strdup(text);
@@ -1779,7 +1783,7 @@ static void eps_write_text(eps_state *state, gfx_node_t *node)
         if (ch > 255) {
             fputc('?', fp);
         } else if (ch >= 126 || ch < 32) {
-          fprintf(fp, "\\%03o", ch);
+          fprintf(fp, "\\%03o", (unsigned int)ch);
           lineLen += 3;
         } else {
           fputc(ch, fp);