[Gpa-commits] r813 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 7 16:22:54 CET 2008


Author: marcus
Date: 2008-02-07 16:22:53 +0100 (Thu, 07 Feb 2008)
New Revision: 813

Modified:
   trunk/src/ChangeLog
   trunk/src/clipboard.c
Log:
2008-02-07  Marcus Brinkmann  <marcus at g10code.de>

	* clipboard.c (dos_to_unix) [G_OS_WIN32]: New function.
	(file_created_cb) [G_OS_WIN32]: Use it.
	(file_open) [G_OS_WIN32]: Use it.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-02-07 15:13:28 UTC (rev 812)
+++ trunk/src/ChangeLog	2008-02-07 15:22:53 UTC (rev 813)
@@ -1,5 +1,9 @@
 2008-02-07  Marcus Brinkmann  <marcus at g10code.de>
 
+	* clipboard.c (dos_to_unix) [G_OS_WIN32]: New function.
+	(file_created_cb) [G_OS_WIN32]: Use it.
+	(file_open) [G_OS_WIN32]: Use it.
+
 	* clipboard.c (file_created_cb): Convert \r\n to \n.
 
 	* clipboard.c (GTK_STOCK_SELECT_ALL) [!GTK_CHECK_VERSION(2,10,0):

Modified: trunk/src/clipboard.c
===================================================================
--- trunk/src/clipboard.c	2008-02-07 15:13:28 UTC (rev 812)
+++ trunk/src/clipboard.c	2008-02-07 15:22:53 UTC (rev 813)
@@ -271,6 +271,29 @@
 }
 
 
+#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;
+}
+
+
 /* Add a file created by an operation to the list */
 static void
 file_created_cb (GpaFileOperation *op, gpa_file_item_t item, gpointer data)
@@ -292,23 +315,7 @@
     }
 
 #ifdef G_OS_WIN32
-  {
-    /* 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 = item->direct_out;
-    dst = item->direct_out;
-    while (*src)
-      {
-	if (src[0] == '\r' && src[1] == '\n')
-	  src++;
-	*(dst++) = *(src++);
-      }
-    *dst = '\0';
-  }
+  dos_to_unix (item->direct_out, &item->direct_out_len);
 #endif
 
   gtk_text_buffer_set_text (clipboard->text_buffer,
@@ -444,7 +451,11 @@
       g_free (filename);
       return;
     }
-  
+
+#ifdef G_OS_WIN32
+  dos_to_unix (contents, &length);
+#endif
+
   gtk_text_buffer_set_text (clipboard->text_buffer, contents, length);
   g_free (contents);
 }



More information about the Gpa-commits mailing list