Hilko Bengen <[EMAIL PROTECTED]> writes:

>>> Could this be related to whether or not there are non-ASCII
>>> characters in the subject?
>>
>> Since the subject was 'diff' or 'subject' I doubt it.
>
> Mhem.
>
>     printf 'äöü\n' | LANG=C ./mailx -s foobar $recipient
>
> will also drop the Subject line.

... and the subject line was forgotten because my previous patch
caused any headers to be dropped from the message.

Okay, here's another patch. Apply to 12.3-4.

Cheers,
-Hilko

diff --git a/sendout.c b/sendout.c
index 5661bb9..7dd6808 100644
--- a/sendout.c
+++ b/sendout.c
@@ -50,6 +50,9 @@ static char sccsid[] = "@(#)sendout.c	2.95 (gritter) 6/16/07";
 #include <unistd.h>
 #include <time.h>
 #include "md5.h"
+#ifdef HAVE_SETLOCALE
+#include <locale.h>
+#endif
 
 /*
  * Mail -- a mail program
@@ -66,7 +69,7 @@ static int attach_file(struct attachment *ap, FILE *fo, int dosign);
 static int attach_message(struct attachment *ap, FILE *fo, int dosign);
 static int make_multipart(struct header *hp, int convert, FILE *fi, FILE *fo,
 		const char *contenttype, const char *charset, int dosign);
-static FILE *infix(struct header *hp, FILE *fi, int dosign);
+static FILE *infix(struct header *hp, FILE *fi, int dosign, int doconvert);
 static int savemail(char *name, FILE *fi);
 static int sendmail_internal(void *v, int recipient_record);
 static enum okay transfer(struct name *to, struct name *mailargs, FILE *input,
@@ -404,7 +407,7 @@ make_multipart(struct header *hp, int convert, FILE *fi, FILE *fo,
  * and return the new file.
  */
 static FILE *
-infix(struct header *hp, FILE *fi, int dosign)
+infix(struct header *hp, FILE *fi, int dosign, int doconvert)
 {
 	FILE *nfo, *nfi;
 	char *tempMail;
@@ -413,6 +416,9 @@ infix(struct header *hp, FILE *fi, int dosign)
 #endif
 	enum mimeclean isclean;
 	enum conversion convert;
+	enum gfield gf = GTO|GSUBJECT|GCC|GBCC|GNL|GCOMMA|GUA
+		|GMSGID|GIDENT|GREF|GDATE;
+
 	char *charset = NULL, *contenttype = NULL;
 	int	lastc = EOF;
 
@@ -427,8 +433,15 @@ infix(struct header *hp, FILE *fi, int dosign)
 	}
 	rm(tempMail);
 	Ftfree(&tempMail);
-	convert = get_mime_convert(fi, &contenttype, &charset,
-			&isclean, dosign);
+	if (doconvert) {
+		convert = get_mime_convert(fi, &contenttype, &charset,
+					   &isclean, dosign);
+		gf |= GMIME;
+	} else {
+		convert = CONV_NONE;
+		contenttype = "text/plain";
+		isclean = MIME_HIGHBIT;
+	}
 #ifdef	HAVE_ICONV
 	tcs = gettcharset();
 	if ((convhdr = need_hdrconv(hp, GTO|GSUBJECT|GCC|GBCC|GIDENT)) != 0 &&
@@ -447,10 +460,8 @@ infix(struct header *hp, FILE *fi, int dosign)
 		}
 	}
 #endif	/* HAVE_ICONV */
-	if (puthead(hp, nfo,
-		   GTO|GSUBJECT|GCC|GBCC|GNL|GCOMMA|GUA|GMIME
-		   |GMSGID|GIDENT|GREF|GDATE,
-		   SEND_MBOX, convert, contenttype, charset)) {
+	if (puthead(hp, nfo, gf, 
+		    SEND_MBOX, convert, contenttype, charset)) {
 		Fclose(nfo);
 		Fclose(nfi);
 #ifdef	HAVE_ICONV
@@ -990,7 +1001,7 @@ hloop:	wantcharset = NULL;
 	loop:	if ((ncs = strchr(wantcharset, ',')) != NULL)
 			*ncs++ = '\0';
 	}
-try:	if ((nmtf = infix(hp, mtf, dosign)) == NULL) {
+try:	if ((nmtf = infix(hp, mtf, dosign, 1)) == NULL) {
 		if (hp->h_charset && (errno == EILSEQ || errno == EINVAL)) {
 			rewind(mtf);
 			hp->h_charset = NULL;
@@ -1002,13 +1013,27 @@ try:	if ((nmtf = infix(hp, mtf, dosign)) == NULL) {
 			goto loop;
 		}
 		/* fprintf(stderr, ". . . message lost, sorry.\n"); */
-		perror("");
-	fail:	senderr++;
+	fail:	
+#ifdef HAVE_SETLOCALE
+		if (strcmp(setlocale(LC_CTYPE, NULL), "C") != 0) {
+#endif
+			perror("");
+			senderr++;
+			rewind(mtf);
+			savedeadletter(mtf);
+			fputs(catgets(catd, CATSET, 187,
+				      ". . . message not sent.\n"), stderr);
+			return STOP;
+#ifdef HAVE_SETLOCALE
+		}
+#endif
+		/* 
+		 * We don't care about failed character map
+		 * conversion attempts if the character class
+		 * is set to the standard ("C") locale.
+		 */
 		rewind(mtf);
-		savedeadletter(mtf);
-		fputs(catgets(catd, CATSET, 187,
-				". . . message not sent.\n"), stderr);
-		return STOP;
+		nmtf = infix(hp, mtf, dosign, 0);
 	}
 	mtf = nmtf;
 	if (dosign) {

Reply via email to