[dia] vdx: bug 683700 - UTF-8 safe variant to remove last newline



commit 99dc2c8bfa2bb3143a0d1f6247b98da2424f21f3
Author: Hans Breuer <hans breuer org>
Date:   Fri Sep 14 19:25:09 2012 +0200

    vdx: bug 683700 - UTF-8 safe variant to remove last newline
    
    With the VDX attached to bug 683700 scrambled text appeared.
    Now corrected with the UTF-8 safe variant to search and
    replace "\n".

 plug-ins/vdx/vdx-import.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index 7b9e350..434a573 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -2259,12 +2259,29 @@ plot_text(const struct vdx_Text *Text, const struct vdx_XForm *XForm,
         }
     }
 
+#if 0 /* this is not utf-8 safe - see bug 683700 */ 
     /* Remove trailing line breaks */
     while (tprop->text_data[0] &&
            isspace(tprop->text_data[strlen(tprop->text_data)-1]))
     {
         tprop->text_data[strlen(tprop->text_data)-1] = 0;
     }
+#else
+    {
+        char *s = tprop->text_data;
+        char *srep = NULL;
+        while ( (s = g_utf8_strchr(s, -1, '\n')) != NULL ) {
+            srep = s;
+            s = g_utf8_next_char(s);
+            if (*s)
+                srep = NULL;
+            else
+                break;
+        }
+        if (srep)
+            *srep = '\0';
+    }
+#endif
 
     /* Other standard text properties */
     tprop->attr.alignment = alignment;



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