SOURCES: pine-send-charset.patch (NEW), pine-config-options.patch ...

blues blues at pld-linux.org
Thu Mar 29 17:06:16 CEST 2007


Author: blues                        Date: Thu Mar 29 15:06:16 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- stollen from SuSE

---- Files affected:
SOURCES:
   pine-send-charset.patch (NONE -> 1.1)  (NEW), pine-config-options.patch (NONE -> 1.1)  (NEW), pine-utf8-mailindx.patch (NONE -> 1.1)  (NEW), pine-mailindx-plusdraw.patch (NONE -> 1.1)  (NEW), pine-gf_wrap-UTF8.patch (NONE -> 1.1)  (NEW), pine-no-stripwhitespace.patch (NONE -> 1.1)  (NEW), pine-strings-iconv.patch (NONE -> 1.1)  (NEW), pine-filter-iconv.patch (NONE -> 1.1)  (NEW), pine-rfc1522_decode.patch (NONE -> 1.1)  (NEW), pine-rfc1522_valid.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/pine-send-charset.patch
diff -u /dev/null SOURCES/pine-send-charset.patch:1.1
--- /dev/null	Thu Mar 29 17:06:16 2007
+++ SOURCES/pine-send-charset.patch	Thu Mar 29 17:06:11 2007
@@ -0,0 +1,306 @@
+#
+# This patch isn't complete yet, the call to filter_msgtxt_to_send_charset
+# has yet to be included into the send filter process (strings2outgoing):
+#
+# Additional description:
+#
+# Thus, for now, ENABLE_SEND_CHARSET is not defined, this means that this
+# patch is for now completely #ifdef'ed out, except for two hunks:
+# 
+# This first hunk changes a variable in the resulting preprocessed code,
+# it ensures that if pine is using a charset for charset conversion,
+# the outgoing mails are also encoded using a charset, to prevent
+# that mails could go out without being encoded correctly, it would
+# show it not on every outgoing mail but one quite some.
+#
+set_mime_charset(pm, ascii_ok, cs):
+
+     if(pm->value && (!*pm->value || strucmp(pm->value, us_ascii) == 0))
+       fs_give((void **)&pm->value);
+
++    cs = cs ? cs
++#ifdef ENABLE_SEND_CHARSET
++       : ps_global->VAR_SEND_CHARSET ? ps_global->VAR_SEND_CHARSET
++#endif
++       : ps_global->VAR_CHAR_SET;
+     /* see if cs is a special non_ascii charset */
+     for(excl = non_ascii; cs && *excl && strucmp(*excl, cs); excl++)
+       ;
+# 
+# This second hunk is an tuned copy of the rule which occurs in the
+# code just before this hunk. It improves the selection of the mime
+# encoding which is used use for encoding mail. Only tunes the
+# efficiency of the mine encoding.
+#
+set_mime_type_by_grope(body, charset):
+
+            if(new_encoding != ENCBINARY)
+              new_encoding = ENC8BIT;  /* short lines, < 30% 8 bit chars */
+        }
++       else if(max_line < 300L || (eight_bit_chars * 100L)/len < 80L){
++           /*
++            * The previous test misses East Asian, Greek and Russian text
++            * in ISO-8859-7, KOI8-R, EUC-KR, Big5, and GB2312
++            * with a lot higher percentage of 8bit chars than Western European text
++            * in ISO-8859-x. For them, use a relaxed condition for the 
++            * percentage of 8bit chars along with a more strict condition
++            * on the maximum line length. 
++            */
++           can_be_ascii--;
++           if(body->type == TYPEOTHER)
++             body->type = TYPETEXT;
++
++           if(new_encoding != ENCBINARY)
++             new_encoding = ENC8BIT;  /* short lines, < 30% 8 bit chars */
++       }
+        else{
+            can_be_ascii--;
+            if(body->type == TYPEOTHER){
+
+--- pine4.59.9z/pine/send.c
++++ pine4.59.9d/pine/send.c
+@@ -6372,6 +6375,54 @@ filter_msgtxt_euc_to_2022_jp(body)
+     }
+ }
+ 
++#ifdef ENABLE_SEND_CHARSET
++/*
++ * Take the PicoText pointed to and replace it with PicoText which has been
++ * filtered to change the 'character-set' (display/terminal-charset) to 
++ * 'send-charset'. (based on filter_msgtxt_euc_to_2022_jp, above)
++ */
++void
++filter_msgtxt_to_send_charset(body)
++    BODY *body;
++{
++    STORE_S **so = (STORE_S **)((body->type == TYPEMULTIPART)
++				? &body->nested.part->body.contents.text.data
++				: &body->contents.text.data);
++    STORE_S  *filtered_so = NULL; 
++    gf_io_t   pc, gc;
++    char     *errstr;
++    CONV_TABLE *ct;
++    char * assumed_save = ps_global->VAR_ASSUMED_CHAR_SET;
++
++    ps_global->VAR_ASSUMED_CHAR_SET = NULL;
++    ct = conversion_table(ps_global->VAR_CHAR_SET, ps_global->VAR_SEND_CHARSET);
++    ps_global->VAR_ASSUMED_CHAR_SET = assumed_save;
++
++    if(ct->table && (filtered_so = so_get(PicoText, NULL, EDIT_ACCESS))){
++	so_seek(*so, 0L, 0);
++	gf_filter_init();
++	gf_link_filter(ct->convert, ct->table);
++	gf_set_so_readc(&gc, *so);
++	gf_set_so_writec(&pc, filtered_so);
++	if(errstr = gf_pipe(gc, pc)){
++	    so_give(&filtered_so);
++	    dprint(1, (debugfile,
++		       "Error with converting to send-charset %s:%s\n", 
++		       ps_global->VAR_SEND_CHARSET, errstr));
++	    return;
++	}
++
++	gf_clear_so_readc(*so);
++	gf_clear_so_writec(filtered_so);
++
++	so_give(so);
++	*so = filtered_so;
++    }
++    dprint(5, (debugfile,
++	       "Succeeded in converting %s to %s for outgoing email\n",
++	       ps_global->VAR_CHAR_SET, ps_global->VAR_SEND_CHARSET));
++}
++#endif
+ 
+ /*----------------------------------------------------------------------
+     Pass the first text segment of the message thru the "send filter"
+@@ -7587,7 +7638,12 @@ outgoing2strings(header, bod, text, pico
+ 		src = pf->scratch ? pf->scratch
+ 				  : (*pf->text) ? *pf->text : "";
+ 
++#ifndef ENABLE_SEND_CHARSET
+		len = strlen(src)+1;
++#else
++		/* multiplyer 5 should be enough for EUC-JP -> ISO-2022-JP */
++		len = strlen(src)*5+1;  
++#endif
+ 		p = (char *)fs_get(len * sizeof(char));
+ 		if(rfc1522_decode((unsigned char *)p, len, src, &charset)
+ 						   == (unsigned char *) p){
+@@ -7718,6 +7770,13 @@ strings2outgoing(header, bod, attach, ch
+ 		         !strucmp(ps_global->VAR_CHAR_SET, "iso-2022-jp"))
+ 		        *pf->text =
+ 			 (char *) trans_euc_to_2022_jp((unsigned char *) (pf->scratch));
++#ifdef ENABLE_SEND_CHARSET
++		      else if(ps_global->VAR_CHAR_SET && ps_global->VAR_SEND_CHARSET &&
++		         !strucmp(ps_global->VAR_CHAR_SET, ps_global->VAR_SEND_CHARSET))
++		        *pf->text =
++			 (char *) trans_with_iconv((unsigned char *) (pf->scratch),
++			   ps_global->VAR_CHAR_SET, ps_global->VAR_SEND_CHARSET);  
++#endif
+ 		      else
+ 		        *pf->text = cpystr(pf->scratch);
+ 		  }
+@@ -7783,6 +7872,10 @@ resolve_encoded_entries(new, old)
+ 					  SIZEOF_20KBUF, buftmp, &charset);
+ 
+ 	      q = (char *) trans_euc_to_2022_jp((unsigned char *)(a->personal));
++#ifdef ENABLE_SEND_CHARSET
++	      q = (char *) trans_with_iconv((unsigned char *)(a->personal),
++		      ps_global->VAR_CHAR_SET, ps_global->VAR_SEND_CHARSET);
++#endif
+ 
+ 	      if(p == tmp_20k_buf		/* personal was decoded */
+ 		 && !strcmp(q, p)){		/* still matches what it was */
+@@ -7881,6 +7980,10 @@ create_message_body(b, attach, charset)
+ 			   rfc1522_encode(tmp_20k_buf,
+ 					  SIZEOF_20KBUF,
+ 					  (unsigned char *) pa->description,
++#ifdef ENABLE_SEND_CHARSET
++					   ps_global->VAR_SEND_CHARSET ? 
++					   ps_global->VAR_SEND_CHARSET :
++#endif
+ 					  ps_global->VAR_CHAR_SET));
+ 	      }
+ 
+@@ -7943,6 +8048,10 @@ create_message_body(b, attach, charset)
+         p->body.description = cpystr(rfc1522_encode(tmp_20k_buf,
+ 					   SIZEOF_20KBUF,
+ 				           (unsigned char *) pa->description,
++#ifdef ENABLE_SEND_CHARSET
++					   ps_global->VAR_SEND_CHARSET ? 
++					   ps_global->VAR_SEND_CHARSET :
++#endif
+ 					   ps_global->VAR_CHAR_SET));
+ 
+ 	/* Add name attribute for backward compatibility */
+@@ -8329,6 +8440,22 @@ set_mime_type_by_grope(body, charset)
+ 	    if(new_encoding != ENCBINARY)
+ 	      new_encoding = ENC8BIT;  /* short lines, < 30% 8 bit chars */
+ 	}
++	else if(max_line < 300L || (eight_bit_chars * 100L)/len < 80L){
++	    /*
++	     * The previous test misses East Asian, Greek and Russian text
++	     * in ISO-8859-7, KOI8-R, EUC-KR, Big5, and GB2312
++	     * with a lot higher percentage of 8bit chars than Western European text
++	     * in ISO-8859-x. For them, use a relaxed condition for the 
++	     * percentage of 8bit chars along with a more strict condition
++	     * on the maximum line length. 
++	     */
++	    can_be_ascii--;
++	    if(body->type == TYPEOTHER)
++	      body->type = TYPETEXT;
++
++	    if(new_encoding != ENCBINARY)
++	      new_encoding = ENC8BIT;  /* short lines, < 30% 8 bit chars */
++	}
+ 	else{
+ 	    can_be_ascii--;
+ 	    if(body->type == TYPEOTHER){
+@@ -8392,7 +8519,11 @@ set_mime_type_by_grope(body, charset)
+ 	else
+ 	  set_mime_charset(pm,
+ 			   can_be_ascii > 0,
++#ifndef ENABLE_SEND_CHARSET
+ 			   charset ? charset : ps_global->VAR_CHAR_SET);
++#else
++			   charset);
++#endif
+     }
+ 
+     if(body->encoding == ENCOTHER)
+@@ -8451,7 +8578,11 @@ set_only_charset_by_grope(body, charset)
+ 
+     set_mime_charset(pm,
+ 		     can_be_ascii > 0,
++#ifndef ENABLE_SEND_CHARSET
+ 		     charset ? charset : ps_global->VAR_CHAR_SET);
++#else
++		     charset);
++#endif
+ 
+     if(we_cancel)
+       cancel_busy_alarm(-1);
+@@ -8482,6 +8609,11 @@ set_mime_charset(pm, ascii_ok, cs)
+     if(pm->value && (!*pm->value || strucmp(pm->value, us_ascii) == 0))
+       fs_give((void **)&pm->value);
+ 
++    cs = cs ? cs
++#ifdef ENABLE_SEND_CHARSET
++	: ps_global->VAR_SEND_CHARSET ? ps_global->VAR_SEND_CHARSET
++#endif
++	: ps_global->VAR_CHAR_SET;
+     /* see if cs is a special non_ascii charset */
+     for(excl = non_ascii; cs && *excl && strucmp(*excl, cs); excl++)
+       ;
+@@ -8566,8 +8700,16 @@ pine_header_line(field, header, text, f,
+     char *value, *folded = NULL;
+ 
+ 
++#ifdef ENABLE_SEND_CHARSET
++    text = (char *) trans_with_iconv(text, ps_global->VAR_CHAR_SET,
++			    ps_global->VAR_SEND_CHARSET);
++#endif
+     value = encode_header_value(tmp_20k_buf, SIZEOF_20KBUF,
+ 				(unsigned char *) text,
++#ifdef ENABLE_SEND_CHARSET
++			        ps_global->VAR_SEND_CHARSET ?
++			        ps_global->VAR_SEND_CHARSET :
++#endif
+ 			        ps_global->VAR_CHAR_SET,
+ 				encode_whole_header(field, header));
+     
+@@ -8632,6 +8776,10 @@ pine_header_line(field, header, text, f,
+ 	  fs_give((void **)&folded);
+     }
+     
++#ifdef ENABLE_SEND_CHARSET
++    if (text)
++	fs_give((void **)&text);
++#endif
+     return(ret);
+ }
+ 
+--- pine4.59.9z/pine/reply.c
++++ pine4.59.9d/pine/reply.c
+@@ -4640,6 +4655,9 @@ bounce_msg(stream, rawno, part, to, subj
+     ENVELOPE *outgoing;
+     BODY     *body = NULL;
+     MESSAGECACHE *mc;
++#ifdef ENABLE_SEND_CHARSET
++    char     *temp_send_cset = NULL;
++#endif
+ 
+     outgoing		 = mail_newenvelope();
+     outgoing->message_id = generate_message_id();
+@@ -4723,6 +4739,17 @@ bounce_msg(stream, rawno, part, to, subj
+ 
+     gf_clear_so_writec((STORE_S *) msgtext);
+ 
++#ifdef ENABLE_SEND_CHARSET
++    /*
++     * reset VAR_SEND_CHARSET to '' temporarily NOT to 
++     * apply  the charset conversion to a bounced message.
++     */
++    if (ps_global->VAR_SEND_CHARSET && *(ps_global->VAR_SEND_CHARSET)){
++	temp_send_cset = (char *)fs_get(strlen(ps_global->VAR_SEND_CHARSET)+1);
++	strcpy(temp_send_cset, ps_global->VAR_SEND_CHARSET);
++	(ps_global->VAR_SEND_CHARSET)[0] = '\0'; 
++    }
++#endif
+     if(pine_simple_send(outgoing, &body, role, pmt_who, pmt_cnf, to,
+ 			!(to && *to) ? SS_PROMPTFORTO : 0) < 0){
+ 	errstr = "";		/* p_s_s() better have explained! */
+@@ -4733,6 +4760,12 @@ bounce_msg(stream, rawno, part, to, subj
+ 	  mail_flag(stream, long2string(rawno), "\\SEEN", 0);
+     }
+ 
++#ifdef ENABLE_SEND_CHARSET
++    if (temp_send_cset){
++	strcpy(ps_global->VAR_SEND_CHARSET, temp_send_cset);
++	fs_give((void **)&temp_send_cset);
++    }
++#endif
+     /* Just for good measure... */
+     mail_free_envelope(&outgoing);
+     pine_free_body(&body);

================================================================
Index: SOURCES/pine-config-options.patch
diff -u /dev/null SOURCES/pine-config-options.patch:1.1
--- /dev/null	Thu Mar 29 17:06:16 2007
+++ SOURCES/pine-config-options.patch	Thu Mar 29 17:06:11 2007
@@ -0,0 +1,116 @@
+--- pine4.59.9z/pine/init.c
++++ pine4.59.9d/pine/init.c
+@@ -219,6 +219,16 @@ CONF_TXT_T cf_text_folder_sort_rule[] =	
+ 
+ CONF_TXT_T cf_text_character_set[] =	"Reflects capabilities of the display you have. Default: US-ASCII.\n# Typical alternatives include ISO-8859-x, (x is a number between 1 and 9).";
+ 
++CONF_TXT_T cf_text_assumed_charset[] =	"When MIME charset information is missing in Content-Type header field.\n# Message is assumed to be in this charset. Default: US-ASCII. Typical values\n# include ISO-8859-x, ISO-2022-JP, EUC-KR, GB2312, and Big5. The value of\n# header fields which are not encoded per RFC 2047\n# is also assumed to be\n# in this charset."; 
++
++CONF_TXT_T cf_text_charset_aliases[] =	"List of charset aliases. Each alias is a pair of charsets delimetered by a\n# single colon, the first one being an alias to the second one. The latter is\n# usually standard/prefered MIME name while the former is non-standard name used\n# by some email clients. For instance, you may have 'x-big5:big5,euc-cn:gb2312'";
++
++#ifdef HAVE_ICONV
++CONF_TXT_T cf_text_iconv_aliases[] =	"List of charset aliases to use with iconv(). Each alias is a pair of\n# charsets delimetered by a single colon, the first one being an alias to the\n# second one. The former is usually standard/prefered MIME name while the\n# latter is non-standard name used by iconv(3) on your system.\n#For example,\n# your iconv may use non-standard 'UTF8' for the standard 'UTF-8'. In that\n# case, you can put 'UTF-8:UTF8' here.";
++
++CONF_TXT_T cf_text_send_charset[] =	"Specifies the MIME charset that a message will be sent in. If not set,\n# the value of character set will be used.";
++#endif
++
+ CONF_TXT_T cf_text_editor[] =		"Specifies the program invoked by ^_ in the Composer,\n# or the \"enable-alternate-editor-implicitly\" feature.";
+ 
+ CONF_TXT_T cf_text_speller[] =		"Specifies the program invoked by ^T in the Composer.";
+@@ -522,6 +532,18 @@ static struct variable variables[] = {
+ 				cf_text_thread_lastreply_char},
+ {"character-set",			0, 1, 0, 1, 1, 0, 0, 0, 0, 0,
+ 				cf_text_character_set},
++#ifdef ENABLE_SEND_CHARSET
++{"send-charset",	 		0, 1, 0, 1, 1, 0, 0, 0, 0, 0,
++				cf_text_send_charset},
++#endif
++{"assumed-charset",			0, 1, 0, 1, 1, 0, 0, 0, 0, 0,
++				cf_text_assumed_charset},
++{"charset-aliases",			0, 1, 0, 1, 1, 1, 0, 0, 0, 0,
++				cf_text_charset_aliases},
++#ifdef HAVE_ICONV
++{"iconv-aliases",			0, 1, 0, 1, 1, 1, 0, 0, 0, 0,
++				cf_text_iconv_aliases},
++#endif
+ {"editor",				0, 1, 0, 1, 1, 1, 0, 0, 0, 1,
+ 				cf_text_editor},
+ {"speller",				0, 1, 0, 1, 1, 0, 0, 0, 0, 0,
+@@ -2059,6 +2084,14 @@ init_vars(ps)
+     set_current_val(&vars[V_SIGNATURE_FILE], TRUE, TRUE);
+     set_current_val(&vars[V_LITERAL_SIG], TRUE, TRUE);
+     set_current_val(&vars[V_CHAR_SET], TRUE, TRUE);
++#ifdef ENABLE_SEND_CHARSET
++    set_current_val(&vars[V_SEND_CHARSET], TRUE, TRUE);
++#endif
++    set_current_val(&vars[V_ASSUMED_CHAR_SET], TRUE, TRUE);
++    set_current_val(&vars[V_CHAR_SET_ALIASES], TRUE, TRUE);
++#ifdef HAVE_ICONV
++    set_current_val(&vars[V_ICONV_ALIASES], TRUE, TRUE);
++#endif
+     set_current_val(&vars[V_GLOB_ADDRBOOK], TRUE, TRUE);
+     set_current_val(&vars[V_ADDRESSBOOK], TRUE, TRUE);
+     set_current_val(&vars[V_FORCED_ABOOK_ENTRY], TRUE, TRUE);
+--- pine4.59.9z/pine/pine.h
++++ pine4.59.9d/pine/pine.h
+@@ -599,6 +600,14 @@ typedef	enum {    V_PERSONAL_NAME = 0
+ 		, V_THREAD_EXP_CHAR
+ 		, V_THREAD_LASTREPLY_CHAR
+ 		, V_CHAR_SET
++#ifdef ENABLE_SEND_CHARSET
++		, V_SEND_CHARSET
++#endif
++		, V_ASSUMED_CHAR_SET
++		, V_CHAR_SET_ALIASES
++#ifdef HAVE_ICONV
++		, V_ICONV_ALIASES
++#endif
+ 		, V_EDITOR
+ 		, V_SPELLER
+ 		, V_FILLCOL
+@@ -839,6 +848,14 @@ typedef	enum {    V_PERSONAL_NAME = 0
+ #define GLO_FLD_SORT_RULE	     vars[V_FLD_SORT_RULE].global_val.p
+ #define VAR_CHAR_SET		     vars[V_CHAR_SET].current_val.p
+ #define GLO_CHAR_SET		     vars[V_CHAR_SET].global_val.p
++#ifdef ENABLE_SEND_CHARSET
++#define VAR_SEND_CHARSET	     vars[V_SEND_CHARSET].current_val.p
++#endif
++#define VAR_ASSUMED_CHAR_SET	     vars[V_ASSUMED_CHAR_SET].current_val.p
++#define VAR_CHAR_SET_ALIASES	     vars[V_CHAR_SET_ALIASES].current_val.l
++#ifdef HAVE_ICONV
++#define VAR_ICONV_ALIASES 	     vars[V_ICONV_ALIASES].current_val.l
++#endif
+ #define VAR_EDITOR		     vars[V_EDITOR].current_val.l
+ #define GLO_EDITOR		     vars[V_EDITOR].global_val.l
+ #define VAR_SPELLER		     vars[V_SPELLER].current_val.p
+--- pine4.59.9z/pine/other.c
++++ pine4.59.9d/pine/other.c
+@@ -7317,6 +7317,18 @@ config_help(var, feature)
+ 	return(h_config_fld_sort_rule);
+       case V_CHAR_SET :
+ 	return(h_config_char_set);
++#ifdef ENABLE_SEND_CHARSET
++      case V_SEND_CHARSET :
++	return(h_config_send_char_set);
++#endif
++      case V_ASSUMED_CHAR_SET :
++	return(h_config_assumed_charset);
++      case V_CHAR_SET_ALIASES :
++	return(h_config_charset_aliases);
++#ifdef HAVE_ICONV
++      case V_ICONV_ALIASES :
++	return(h_config_iconv_aliases);
++#endif
+       case V_EDITOR :
+ 	return(h_config_editor);
+       case V_SPELLER :
+@@ -11751,6 +11761,9 @@ toggle_feature_bit(ps, index, var, cl, j
+       case F_PASS_C1_CONTROL_CHARS :
+ 	ps->pass_c1_ctrl_chars = F_ON(F_PASS_C1_CONTROL_CHARS,ps_global)
+ 								    ? 1 : 0;
++	if(ps_global->VAR_CHAR_SET
++	 && !strucmp(ps_global->VAR_CHAR_SET, "UTF-8"))
++	  ps->pass_c1_ctrl_chars = 1;
+ 	break;
+ #endif
+ #ifdef	MOUSE

================================================================
Index: SOURCES/pine-utf8-mailindx.patch
diff -u /dev/null SOURCES/pine-utf8-mailindx.patch:1.1
--- /dev/null	Thu Mar 29 17:06:16 2007
+++ SOURCES/pine-utf8-mailindx.patch	Thu Mar 29 17:06:11 2007
@@ -0,0 +1,199 @@
+diff -pruN -x '*~' -x '*.orig' -x '*.rej' pine4.63-patch28/pine/mailindx.c pine4.63/pine/mailindx.c
+--- pine4.63-patch28/pine/mailindx.c	2005-05-10 22:30:45.000000000 +0200
++++ pine4.63/pine/mailindx.c	2005-05-11 00:52:20.173941845 +0200
+@@ -4627,6 +4627,58 @@ day_of_year(d)
+     return(doy);
+ }
+ 
++static char *
++rfc_1522_check_charset(chp)
++    char *chp;
++{
++    static char *subj_cs = NULL;
++    char *cs, *enc;
++
++    while(chp && (chp = strstr(chp, "=?")))
++	if(rfc1522_valid(chp++, 1, &cs, &enc, NULL, NULL)){
++	    int cs_len = enc - cs - 1;
++
++	    if(subj_cs)
++		fs_give((void **)&subj_cs);
++
++	    strncpy(subj_cs = fs_get(cs_len + 1), cs, cs_len);
++	    subj_cs[cs_len] = 0;
++
++	    return subj_cs;
++	}
++    return NULL;
++}
++
++static void
++rfc1522_decode_width(dest, source, width, idata)
++    char	*dest;
++    char	*source;
++    int		 width;
++    INDEXDATA_S *idata;
++{
++    char *subj_cs, *assumed_save = NULL, *dummy = NULL, *tmp;
++
++    if(idata && (subj_cs = rfc_1522_check_charset(fetch_subject(idata)))){
++	assumed_save = ps_global->VAR_ASSUMED_CHAR_SET;
++	ps_global->VAR_ASSUMED_CHAR_SET = subj_cs;
++    }
++
++    tmp = (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
++				   SIZEOF_20KBUF, source, &dummy);
++    if(idata){
++	if(tmp == source)
++	    strncpy(tmp = tmp_20k_buf, source, SIZEOF_20KBUF);
++
++	removing_leading_and_trailing_white_space(tmp);
++
++	if(subj_cs)
++	    ps_global->VAR_ASSUMED_CHAR_SET = assumed_save;
++    }
++    charset_istrncpy(dest, tmp, width, 0);
++	
++    if(dummy)
++	fs_give((void **)&dummy);
++}
+ 
+ 
+ /*----------------------------------------------------------------------
+@@ -4643,7 +4695,8 @@ HLINE_S *
+ format_index_index_line(idata)
+     INDEXDATA_S	*idata;
+ {
+-    char          str_buf[MAXIFLDS][MAX_SCREEN_COLS+1], to_us, status, *field,
++#define STRLEN MAX_SCREEN_COLS*6
++    char          str_buf[MAXIFLDS][STRLEN+1], to_us, status, *field,
+ 		 *buffer, *s_tmp, *p, *str, *newsgroups;
+     int		  width, i, j, smallest, which_array = 0, collapsed = 0,
+ 		  offsets_set = 0, cur_offset = 0, noff = 0, noff_was;
+@@ -5128,7 +5181,7 @@ format_index_index_line(idata)
+ 	      case iFrom:
+ 	      case iAddress:
+ 	      case iMailbox:
+-		from_str(cdesc->ctype, idata, width, str);
++		from_str(cdesc->ctype, idata, min(width*6,STRLEN), str);
+ 	        break;
+ 
+ 	      case iTo:
+@@ -5445,12 +5498,12 @@ getsize:
+ 		break;
+ 
+ 	      case iSubject:
+-		subj_str(idata, width, str, NoKW, NULL, NULL);
++		subj_str(idata, min(width*6,STRLEN), str, NoKW, NULL, NULL);
+ 		break;
+ 
+ 	      case iSubjKey:
+ 		noff_was = noff;
+-		subj_str(idata, width, str, KW, hline->offs, &noff);
++		subj_str(idata, min(width*6,STRLEN), str, KW, hline->offs, &noff);
+ 		/* fix offsets which are now relative to str */
+ 		for(i = noff_was; i < noff; i++)
+ 		  if(hline->offs[i].offset >= 0)
+@@ -5631,34 +5684,11 @@ getsize:
+ 	  }
+ 
+ 	  if(cdesc->adjustment == Left)
+-	    sprintf(p, "%-*.*s", width, width, str);
++	    charset_istrncpy(p, str, width, 1);
+ 	  else
+ 	    sprintf(p, "%*.*s", width, width, str);
+ 
+-	  /*
+-	   * Make sure there are no nulls in the part we were supposed to
+-	   * have just written. This may happen if sprintf returns an
+-	   * error, but we don't want to check for that because some
+-	   * sprintfs don't return anything. If there are nulls, rewrite it.
+-	   */
+-	  for(q = p; q < p+width; q++)
+-	    if(*q == '\0')
+-	      break;
+-	    
+-	  if(q < p+width){
+-	      strncpy(p, repeat_char(width, ' '), width);
+-	      p[width] = '\0';
+-	      /* throw a ? in there too */
+-	      if(width > 4){
+-		  p[(width-1)/2 - 1] = '?';
+-		  p[(width-1)/2    ] = '?';
+-		  p[(width-1)/2 + 1] = '?';
+-	      }
+-	      else if(width > 2)
+-		p[(width-1)/2] = '?';
+-	  }
+-
+-	  p += width;
++	  p += strlen(p);
+       }
+ 
+ 	
+@@ -5687,7 +5717,7 @@ getsize:
+     }
+ 
+     /* Truncate it to be sure not too wide */
+-    buffer[min(ps_global->ttyo->screen_cols, i_cache_width())] = '\0';
++    buffer[i_cache_width()] = '\0';
+     hline->id = line_hash(buffer);
+     dprint(9, (debugfile, "INDEX(%p) -->%s<-- (%d), 0x%lx>\n",
+ 	       hline,
+@@ -6537,21 +6567,12 @@ set_index_addr(idata, field, addr, prefi
+     if(addr && !addr->next		/* only one address */
+        && addr->host			/* not group syntax */
+        && addr->personal && addr->personal[0]){	/* there is a personal name */
+-	char *dummy = NULL;
+-	char  buftmp[MAILTMPLEN];
+ 	int   l;
+ 
+ 	if(l = prefix ? strlen(prefix) : 0)
+ 	  strcpy(s, prefix);
+ 
+-	sprintf(buftmp, "%.75s", addr->personal);
+-	p = (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
+-				    SIZEOF_20KBUF, buftmp, &dummy);
+-	removing_leading_and_trailing_white_space(p);
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list