improve insert DOS/MAC file
authorPaul Mangan <paul@claws-mail.org>
Wed, 24 Oct 2001 07:57:55 +0000 (07:57 +0000)
committerPaul Mangan <paul@claws-mail.org>
Wed, 24 Oct 2001 07:57:55 +0000 (07:57 +0000)
ChangeLog.claws
configure.in
src/compose.c

index ae52c4c..e830eaa 100644 (file)
@@ -1,3 +1,14 @@
+2001-10-24 [paul]      0.6.4claws2
+
+       * src/prefs_common.c
+               gettextize the gpg ascii-armored warning message
+
+       * src/compose.c
+               insert a DOS/MAC file into the composed message
+               (improvements)
+
+       * Both submitted by Thierry Godefroy <godefroy@imaginet.fr>
+
 2001-10-22 [paul]      0.6.4claws1
 
        * sync with sylpheed 0.6.4 release
index 497532a..ad7b2b1 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws1
+EXTRA_VERSION=claws2
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index 191c3f0..8dc5dc1 100644 (file)
@@ -1853,6 +1853,7 @@ static void compose_insert_file(Compose *compose, const gchar *file)
 {
        GtkSText *text = GTK_STEXT(compose->text);
        gchar buf[BUFFSIZE];
+       gint len;
        FILE *fp;
 
        g_return_if_fail(file != NULL);
@@ -1865,10 +1866,17 @@ static void compose_insert_file(Compose *compose, const gchar *file)
        gtk_stext_freeze(text);
 
        while (fgets(buf, sizeof(buf), fp) != NULL) {
-               if (strlen(buf) > 1 && buf[strlen(buf) - 2] == '\r' && buf[strlen(buf) - 1] == '\n') {
-                       buf[strlen(buf) - 2] = '\n';
-                       buf[strlen(buf) - 1] = 0;
+               /* Strip <CR> if DOS/Windoze file, replace <CR> with <LF> if MAC file */
+               len = strlen(buf);
+               if (len > 1 && buf[len - 2] == '\r' && buf[len - 1] == '\n') {
+                       buf[len - 2] = '\n';
+                       buf[len - 1] = '\0';
+               } else {
+                       while (--len > 0)
+                               if (buf[len] == '\r')
+                                       buf[len] = '\n';
                }
+
                gtk_stext_insert(text, NULL, NULL, NULL, buf, -1);
        }