[dia/dia-0-97] Bug 603576 - wrong decimal separator with vdx



commit 1469bf500d9323ff30ed9d24f6dc531fd69c7b1a
Author: Hans Breuer <hans breuer org>
Date:   Sat Dec 5 19:20:21 2009 +0100

    Bug 603576 - wrong decimal separator with vdx
    
    Temporarily switch to LC_NUMERIC, "C" in import and export callback.
    (cherry picked from commit 5786137095d49a0064cfe1bfe18865383bdc9908)

 plug-ins/vdx/vdx-export.c |    7 +++++++
 plug-ins/vdx/vdx-import.c |   10 ++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index a8e4df2..51c146c 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -1842,6 +1842,7 @@ export_vdx(DiagramData *data, const gchar *filename,
     VDXRenderer *renderer;
     int i;
     Layer *layer;
+    char* old_locale;
 
     file = g_fopen(filename, "w");
 
@@ -1851,6 +1852,9 @@ export_vdx(DiagramData *data, const gchar *filename,
         return;
     }
 
+    /* ugly, but still better than creatin corrupt files */
+    old_locale = setlocale(LC_NUMERIC, "C");
+
     /* Create and initialise our renderer */
     renderer = g_object_new(VDX_TYPE_RENDERER, NULL);
 
@@ -1895,6 +1899,9 @@ export_vdx(DiagramData *data, const gchar *filename,
 
     g_object_unref(renderer);
 
+    /* dont screw Dia's global state */
+    setlocale(LC_NUMERIC, old_locale);
+
     fclose(file);
 }
 
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index f003783..ffefa58 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -36,6 +36,7 @@
 #include <libxml/xmlmemory.h>
 #include <float.h>
 #include <sys/stat.h>
+#include <locale.h>
 
 #include "intl.h"
 #include "message.h"
@@ -2993,6 +2994,7 @@ import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
     int visio_version = 0;
     const char *debug = 0;
     unsigned int debug_shapes = 0;
+    char* old_locale;
 
     if (!doc) {
         message_warning("parse error for %s",
@@ -3029,6 +3031,10 @@ import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
     theDoc = g_new0(struct VDXDocument, 1);
     theDoc->ok = TRUE;
 
+    
+    /* ugly, but still better than bogus sizes */
+    old_locale = setlocale(LC_NUMERIC, "C");
+
     /* VDX_DEBUG sets verbose per-shape debugging on */
     if (g_getenv("VDX_DEBUG")) theDoc->debug_comments = TRUE;
 
@@ -3080,6 +3086,10 @@ import_vdx(const gchar *filename, DiagramData *dia, void* user_data)
     /* Get rid of internal strings before returning */
     vdx_free(theDoc);
     xmlFreeDoc(doc);
+    
+    /* dont screw Dia's global state */
+    setlocale(LC_NUMERIC, old_locale);
+
     return TRUE;
 }
 



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