sync with 0.8.11cvs2
authorPaul Mangan <paul@claws-mail.org>
Mon, 10 Mar 2003 09:54:40 +0000 (09:54 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 10 Mar 2003 09:54:40 +0000 (09:54 +0000)
12 files changed:
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/codeconv.c
src/codeconv.h
src/common/utils.c
src/common/utils.h
src/compose.c
src/headerview.c
src/summaryview.c
src/textview.c

index 273591d..079b9e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2003-03-10
+
+       * src/headerview.c: headerview_show()
+         src/textview.c: textview_write_line(): remove unreadable characters
+         from displayed strings to prevent crashes on multi-byte
+         environments.
+       * src/codeconv.[ch]: conv_unreadable_locale(): new. It was separated
+         from conv_localetodisp().
+
+2003-03-10
+
+       * src/procmsg.c: procmsg_cmp_by_subject()
+         src/summaryview.c: summary_cmp_by_subject(): ignore Re: when
+         comparing subjects.
+       * src/utils.[ch]:
+         subject_compare_for_sort()
+         trim_subject_for_sort(): new.
+
 2003-03-07
 
        * version 0.8.11
index 4203a55..c3902a5 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-10 [paul]      0.8.10claws104
+
+       * sync with 0.8.11cvs2
+               see ChangeLog 2003-03-10
+
 2003-03-09 [melvin]    0.8.10claws103
 
        * src/textview.c
index 8a057e1..93ffc30 100644 (file)
@@ -1,3 +1,21 @@
+2003-03-10
+
+       * src/headerview.c: headerview_show()
+         src/textview.c: textview_write_line(): ¥Þ¥ë¥Á¥Ð¥¤¥È´Ä¶­¤Ç¤Î
+         ¥¯¥é¥Ã¥·¥å¤òËɤ°¤¿¤á¤Ëɽ¼¨Ê¸»úÎ󤫤éɽ¼¨ÉÔǽ¤Êʸ»ú¤òºï½ü¤¹¤ë¤è¤¦¤Ë
+         ¤·¤¿¡£
+       * src/codeconv.[ch]: conv_unreadable_locale(): ¿·µ¬¡£
+         conv_localetodisp() ¤«¤éʬΥ¡£
+
+2003-03-10
+
+       * src/procmsg.c: procmsg_cmp_by_subject()
+         src/summaryview.c: summary_cmp_by_subject(): ·ï̾¤òÈæ³Ó¤¹¤ë¤È¤­¤Ë
+         Re: ¤ò̵»ë¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * src/utils.[ch]:
+         subject_compare_for_sort()
+         trim_subject_for_sort(): ¿·µ¬¡£
+
 2003-03-07
 
        * version 0.8.11
index 195ef00..19979df 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws103
+EXTRA_VERSION=claws104
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index b2d40df..fb0baab 100644 (file)
@@ -462,6 +462,34 @@ void conv_unreadable_latin(gchar *str)
        }
 }
 
+void conv_unreadable_locale(gchar *str)
+{
+       switch (conv_get_current_charset()) {
+       case C_US_ASCII:
+       case C_ISO_8859_1:
+       case C_ISO_8859_2:
+       case C_ISO_8859_3:
+       case C_ISO_8859_4:
+       case C_ISO_8859_5:
+       case C_ISO_8859_6:
+       case C_ISO_8859_7:
+       case C_ISO_8859_8:
+       case C_ISO_8859_9:
+       case C_ISO_8859_10:
+       case C_ISO_8859_11:
+       case C_ISO_8859_13:
+       case C_ISO_8859_14:
+       case C_ISO_8859_15:
+               conv_unreadable_latin(str);
+               break;
+       case C_EUC_JP:
+               conv_unreadable_eucjp(str);
+               break;
+       default:
+               break;
+       }
+}
+
 #define NCV    '\0'
 
 void conv_mb_alnum(gchar *str)
@@ -606,39 +634,15 @@ void conv_latintodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
        conv_unreadable_latin(outbuf);
 }
 
-void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
+void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        strncpy2(outbuf, inbuf, outlen);
+       conv_unreadable_locale(outbuf);
 }
 
-void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
+void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
 {
        strncpy2(outbuf, inbuf, outlen);
-
-       switch (conv_get_current_charset()) {
-       case C_US_ASCII:
-       case C_ISO_8859_1:
-       case C_ISO_8859_2:
-       case C_ISO_8859_3:
-       case C_ISO_8859_4:
-       case C_ISO_8859_5:
-       case C_ISO_8859_6:
-       case C_ISO_8859_7:
-       case C_ISO_8859_8:
-       case C_ISO_8859_9:
-       case C_ISO_8859_10:
-       case C_ISO_8859_11:
-       case C_ISO_8859_13:
-       case C_ISO_8859_14:
-       case C_ISO_8859_15:
-               conv_unreadable_latin(outbuf);
-               break;
-       case C_EUC_JP:
-               conv_unreadable_eucjp(outbuf);
-               break;
-       default:
-               break;
-       }
 }
 
 CodeConverter *conv_code_converter_new(const gchar *charset)
index 13f9aa0..7633f9f 100644 (file)
@@ -159,26 +159,28 @@ struct _CodeConverter
 #define CS_GEORGIAN_PS         "GEORGIAN-PS"
 #define CS_TCVN5712_1          "TCVN5712-1"
 
-void conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytoeuc(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_anytojis(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_unreadable_eucjp(gchar *str);
-void conv_unreadable_8bit(gchar *str);
-void conv_unreadable_latin(gchar *str);
+void conv_jistoeuc     (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_euctojis     (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_sjistoeuc    (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_anytoeuc     (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_anytojis     (gchar *outbuf, gint outlen, const gchar *inbuf);
+
+void conv_unreadable_eucjp     (gchar *str);
+void conv_unreadable_8bit      (gchar *str);
+void conv_unreadable_latin     (gchar *str);
+void conv_unreadable_locale    (gchar *str);
+
 void conv_mb_alnum(gchar *str);
 
 CharSet conv_guess_ja_encoding(const gchar *str);
 
-void conv_jistodisp  (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_sjistodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_euctodisp  (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_ustodisp   (gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_latintodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
-void conv_noconv     (gchar *outbuf, gint outlen, const gchar *inbuf);
-
-void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_jistodisp    (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_sjistodisp   (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_euctodisp    (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_ustodisp     (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_latintodisp  (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_noconv       (gchar *outbuf, gint outlen, const gchar *inbuf);
+void conv_localetodisp (gchar *outbuf, gint outlen, const gchar *inbuf);
 
 CodeConverter *conv_code_converter_new (const gchar    *charset);
 void conv_code_converter_destroy       (CodeConverter  *conv);
index 0d49ca6..ce69f9b 100644 (file)
@@ -506,15 +506,33 @@ gint subject_compare(const gchar *s1, const gchar *s2)
        Xstrdup_a(str1, s1, return -1);
        Xstrdup_a(str2, s2, return -1);
 
-       trim_subject(str1);
-       trim_subject(str2);
+       trim_subject_for_compare(str1);
+       trim_subject_for_compare(str2);
 
        if (!*str1 || !*str2) return -1;
 
        return strcmp(str1, str2);
 }
 
-void trim_subject(gchar *str)
+gint subject_compare_for_sort(const gchar *s1, const gchar *s2)
+{
+       gchar *str1, *str2;
+
+       if (!s1 || !s2) return -1;
+       if (!*s1 || !*s2) return -1;
+
+       Xstrdup_a(str1, s1, return -1);
+       Xstrdup_a(str2, s2, return -1);
+
+       trim_subject_for_sort(str1);
+       trim_subject_for_sort(str2);
+
+       if (!*str1 || !*str2) return -1;
+
+       return strcasecmp(str1, str2);
+}
+
+void trim_subject_for_compare(gchar *str)
 {
        gchar *srcp;
 
@@ -529,6 +547,55 @@ void trim_subject(gchar *str)
        }
 }
 
+void trim_subject_for_sort(gchar *str)
+{
+       gchar *srcp;
+
+       g_strstrip(str);
+
+       while (!strncasecmp(str, "Re:", 3)) {
+               srcp = str + 3;
+               while (isspace(*srcp)) srcp++;
+               memmove(str, srcp, strlen(srcp) + 1);
+       }
+}
+
+void trim_subject(gchar *str)
+{
+       register gchar *srcp, *destp;
+       gchar op, cl;
+       gint in_brace;
+
+       destp = str;
+       while (!strncasecmp(destp, "Re:", 3)) {
+               destp += 3;
+               while (isspace(*destp)) destp++;
+       }
+
+       if (*destp == '[') {
+               op = '[';
+               cl = ']';
+       } else if (*destp == '(') {
+               op = '(';
+               cl = ')';
+       } else
+               return;
+
+       srcp = destp + 1;
+       in_brace = 1;
+       while (*srcp) {
+               if (*srcp == op)
+                       in_brace++;
+               else if (*srcp == cl)
+                       in_brace--;
+               srcp++;
+               if (in_brace == 0)
+                       break;
+       }
+       while (isspace(*srcp)) srcp++;
+       memmove(destp, srcp, strlen(srcp) + 1);
+}
+
 void eliminate_parenthesis(gchar *str, gchar op, gchar cl)
 {
        register gchar *srcp, *destp;
index f2ae599..7529712 100644 (file)
@@ -219,6 +219,10 @@ gint get_next_word_len             (const gchar *s);
 /* functions for string parsing */
 gint subject_compare                   (const gchar    *s1,
                                         const gchar    *s2);
+gint subject_compare_for_sort          (const gchar    *s1,
+                                        const gchar    *s2);
+void trim_subject_for_compare          (gchar          *str);
+void trim_subject_for_sort             (gchar          *str);
 void trim_subject                      (gchar          *str);
 void eliminate_parenthesis             (gchar          *str,
                                         gchar           op,
index 36946db..feb69f6 100644 (file)
@@ -3396,6 +3396,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
                                return -1;
                        } else {
                                buf = chars;
+                               out_codeset = src_codeset;
                                chars = NULL;
                        }
                }
index 8a6853b..e98c748 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2003 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
 #include "intl.h"
 #include "headerview.h"
 #include "prefs_common.h"
+#include "codeconv.h"
 #include "gtkutils.h"
 #include "utils.h"
 
@@ -167,25 +168,38 @@ void headerview_init(HeaderView *headerview)
 
 void headerview_show(HeaderView *headerview, MsgInfo *msginfo)
 {
+       gchar *str;
+
        headerview_clear(headerview);
 
+       if (msginfo->from) {
+               Xstrdup_a(str, msginfo->from, return);
+               conv_unreadable_locale(str);
+       } else
+               str = NULL;
        gtk_label_set_text(GTK_LABEL(headerview->from_body_label),
-                          msginfo->from ? msginfo->from : _("(No From)"));
+                          str ? str : _("(No From)"));
        if (msginfo->to) {
-               gtk_label_set_text(GTK_LABEL(headerview->to_body_label),
-                                  msginfo->to);
+               Xstrdup_a(str, msginfo->to, return);
+               conv_unreadable_locale(str);
+               gtk_label_set_text(GTK_LABEL(headerview->to_body_label), str);
                gtk_widget_show(headerview->to_header_label);
                gtk_widget_show(headerview->to_body_label);
        }
        if (msginfo->newsgroups) {
-               gtk_label_set_text(GTK_LABEL(headerview->ng_body_label),
-                                  msginfo->newsgroups);
+               Xstrdup_a(str, msginfo->newsgroups, return);
+               conv_unreadable_locale(str);
+               gtk_label_set_text(GTK_LABEL(headerview->ng_body_label), str);
                gtk_widget_show(headerview->ng_header_label);
                gtk_widget_show(headerview->ng_body_label);
        }
+       if (msginfo->subject) {
+               Xstrdup_a(str, msginfo->subject, return);
+               conv_unreadable_locale(str);
+       } else
+               str = NULL;
        gtk_label_set_text(GTK_LABEL(headerview->subject_body_label),
-                          msginfo->subject ? msginfo->subject :
-                          _("(No Subject)"));
+                          str ? str : _("(No Subject)"));
 
 #if HAVE_LIBCOMPFACE
        headerview_show_xface(headerview, msginfo);
index c2f3317..b88a3af 100644 (file)
@@ -365,9 +365,6 @@ static gint summary_cmp_by_date             (GtkCList               *clist,
 static gint summary_cmp_by_from                (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
-static gint summary_cmp_by_subject     (GtkCList               *clist,
-                                        gconstpointer           ptr1,
-                                        gconstpointer           ptr2);
 static gint summary_cmp_by_simplified_subject
                                        (GtkCList               *clist, 
                                         gconstpointer           ptr1, 
@@ -381,6 +378,9 @@ static gint summary_cmp_by_label    (GtkCList               *clist,
 static gint summary_cmp_by_to          (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
+static gint summary_cmp_by_subject     (GtkCList               *clist,
+                                        gconstpointer           ptr1,
+                                        gconstpointer           ptr2);
 static gint summary_cmp_by_locked      (GtkCList               *clist,
                                         gconstpointer           ptr1, 
                                         gconstpointer           ptr2);
@@ -5002,11 +5002,26 @@ static gint func_name(GtkCList *clist,                                   \
        return strcasecmp(msginfo1->var_name, msginfo2->var_name);       \
 }
 
-CMP_FUNC_DEF(summary_cmp_by_subject, subject);
 CMP_FUNC_DEF(summary_cmp_by_to, to);
 
 #undef CMP_FUNC_DEF
 
+static gint summary_cmp_by_subject(GtkCList *clist,                     \
+                                  gconstpointer ptr1,                   \
+                                  gconstpointer ptr2)                   \
+{                                                                       \
+       MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;                 \
+       MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;                 \
+                                                                        \
+       if (!msginfo1->subject)                                          \
+               return (msginfo2->subject != NULL);                      \
+       if (!msginfo2->subject)                                          \
+               return -1;                                               \
+                                                                        \
+       return subject_compare_for_sort                                  \
+               (msginfo1->subject, msginfo2->subject);                  \
+}
+
  static gint summary_cmp_by_from(GtkCList *clist, gconstpointer ptr1,
                                 gconstpointer ptr2)
  {
index babf654..fe24af8 100644 (file)
@@ -1174,22 +1174,15 @@ static void textview_write_line(TextView *textview, const gchar *str,
        GdkColor *fg_color;
        gint quotelevel = -1;
 
-#if 0
-       if (!conv)
-               strncpy2(buf, str, sizeof(buf));
-       else if (conv_convert(conv, buf, sizeof(buf), str) < 0) {
-               gtk_stext_insert(text, textview->msgfont,
-                               prefs_common.enable_color
-                               ? &error_color : NULL, NULL,
-                               "*** Warning: code conversion failed ***\n",
-                               -1);
-               return;
-       }
-#endif
-       if (!conv)
-               strncpy2(buf, str, sizeof(buf));
-       else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
+       if (!conv) {
+               if (textview->text_is_mb)
+                       conv_localetodisp(buf, sizeof(buf), str);
+               else
+                       strncpy2(buf, str, sizeof(buf));
+       } else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
                conv_localetodisp(buf, sizeof(buf), str);
+       else if (textview->text_is_mb)
+               conv_unreadable_locale(buf);
 
        strcrchomp(buf);
        if (prefs_common.conv_mb_alnum) conv_mb_alnum(buf);
@@ -1481,6 +1474,9 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                    procheader_headername_equal(header->name, "Cc"))
                        unfold_line(header->body);
 
+               if (textview->text_is_mb == TRUE)
+                       conv_unreadable_locale(header->body);
+
                if (prefs_common.enable_color &&
                    (procheader_headername_equal(header->name, "X-Mailer") ||
                     procheader_headername_equal(header->name,