[Gpa-commits] r845 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 11 17:51:21 CET 2008


Author: marcus
Date: 2008-03-11 17:51:20 +0100 (Tue, 11 Mar 2008)
New Revision: 845

Modified:
   trunk/src/ChangeLog
   trunk/src/gpgmetools.c
Log:
2008-03-11  Marcus Brinkmann  <marcus at g10code.de>

	* gpgmetools.c (dos_to_unix) [G_OS_WIN32]: New function.
	(dump_data_to_clipboard) [G_OS_WIN32]: Convert newlines.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-03-11 15:45:52 UTC (rev 844)
+++ trunk/src/ChangeLog	2008-03-11 16:51:20 UTC (rev 845)
@@ -1,3 +1,8 @@
+2008-03-11  Marcus Brinkmann  <marcus at g10code.de>
+
+	* gpgmetools.c (dos_to_unix) [G_OS_WIN32]: New function.
+	(dump_data_to_clipboard) [G_OS_WIN32]: Convert newlines.
+
 2008-03-11  Werner Koch  <wk at g10code.com>
 
 	* selectkeydlg.c (select_key_dlg_constructor): List only encrypt keys.

Modified: trunk/src/gpgmetools.c
===================================================================
--- trunk/src/gpgmetools.c	2008-03-11 15:45:52 UTC (rev 844)
+++ trunk/src/gpgmetools.c	2008-03-11 16:51:20 UTC (rev 845)
@@ -249,8 +249,34 @@
   return err;
 }
 
-/* Write the contents of the gpgme_data_t into the clipboard.  */
+
+#ifdef G_OS_WIN32
 void
+dos_to_unix (gchar *str, gsize *len)
+{
+  /* On Windows 2000, we need to convert \r\n to \n in the output for
+     cut & paste to work properly (otherwise, extra newlines will be
+     inserted).  */
+  gchar *src;
+  gchar *dst;
+  
+  src = str;
+  dst = str;
+  while (*src)
+    {
+      if (src[0] == '\r' && src[1] == '\n')
+	src++;
+      *(dst++) = *(src++);
+    }
+  *dst = '\0';
+  *len = dst - str;
+}
+#endif
+
+
+/* Write the contents of the gpgme_data_t into the clipboard.  Assumes
+   that the data is ASCII.  */
+void
 dump_data_to_clipboard (gpgme_data_t data, GtkClipboard *clipboard)
 {
   char buffer[128];
@@ -275,6 +301,11 @@
       gpa_window_error (strerror (errno), NULL);
       exit (EXIT_FAILURE);
     }
+
+#ifdef G_OS_WIN32
+  dos_to_unix (text, &len);
+#endif
+
   gtk_clipboard_set_text (clipboard, text, len);
   g_free (text);
   return;



More information about the Gpa-commits mailing list