-.TH MH-PROFILE %manext5% "September 29, 2016" "%nmhversion%"
+.TH MH-PROFILE %manext5% "October 19, 2016" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
only mandatory profile entry. (profile, no default)
.RE
.PP
+.BR locale :
+locale
+.RS 5
+Set the locale for all
+.B nmh
+programs except
+.BR post ,
+.BR install-mh ,
+and
+.BR slocal .
+See the LC_ALL, LC_CTYPE, and LANG variables in the "ENVIRONMENT"
+section below for a reference on how the locale is set if this profile
+component is not used.
+.RE
+.PP
.BR context :
context
.RS 5
whose names are lower-case only are used internally by nmh and should
not generally be set by the user.
.TP
+LC_ALL, LC_CTYPE, and LANG
+These variables are used to set the locale, see locale(1).
+The \*(lqlocale\*(rq profile entry supersedes these.
+.TP
MAILDROP
This variable tells
.B inc
int
nmh_init(const char *argv0, int read_context) {
- if (! setlocale(LC_ALL, "")) {
- admonish(NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and "
- "LANG environment variables");
- }
+ int status = OK;
+ char *locale;
invo_name = r1bindex ((char *) argv0, '/');
putchar ('\n');
}
}
-
- return OK;
} else {
- int status = context_foil(NULL);
- if (status != OK) {
+ if ((status = context_foil(NULL)) != OK) {
advise("", "failed to create minimal profile/context");
}
- return status;
}
+
+ /* Allow the user to set a locale in their profile. Otherwise, use the
+ "" string to pull it from their environment, see setlocale(3). */
+ if ((locale = context_find ("locale")) == NULL) {
+ locale = "";
+ }
+
+ if (! setlocale (LC_ALL, locale)) {
+ admonish (NULL, "setlocale failed, check your LC_ALL, LC_CTYPE, and "
+ "LANG environment variables");
+ }
+
+ return status;
}
#
# It's hard to calculate the exact Date: header post is going to
# use, so we'll just use sed to remove the actual date so we can easily
- # compare it against our "correct" output. And same for charset.
+ # compare it against our "correct" output. And same for charset,
+ # because mime_type() can rely on file(1) --mime-encoding.
#
sed -e 's/^Date:.*/Date:/' -e 's/; charset="[^;]*//' \
"`mhpath cur`" > "${testname}.actual"
From: Mr Nobody <nobody@example.com>
To: Somebody <somebody@example.com>
Subject: Test
-Attach: $MH_TEST_DIR/attachment.txt
+Nmh-Attach: $MH_TEST_DIR/attachment.txt
This is a test.
EOF
From: Mr Nobody <nobody@example.com>
To: Somebody <somebody@example.com>
Subject: Test
-Attach: $MH_TEST_DIR/attachment.txt
+Nmh-Attach: $MH_TEST_DIR/attachment.txt
¡Ay, caramba!
EOF
From: Mr Nobody <nobody@example.com>
To: Somebody <somebody@example.com>
Subject: Test
-Attach: $MH_TEST_DIR/attachment.txt
+Nmh-Attach: $MH_TEST_DIR/attachment.txt
EOF
cat > "${testname}.expected" <<EOF
From: Mr Nobody <nobody@example.com>
To: Somebody <somebody@example.com>
Subject: Test
-Attach: $MH_TEST_DIR/attachment.txt
+Nmh-Attach: $MH_TEST_DIR/attachment.txt
¡Ay, caramba!
EOF
check "$expected" "$actual"
+# previous test, but with locale profile entry
+start_test '8-bit body with C locale with locale profile entry'
+
+printf 'locale: en_US.UTF-8\n' >> "${MH}"
+
+cat > "${testname}.expected" <<EOF
+From: Mr Nobody <nobody@example.com>
+To: Somebody <somebody@example.com>
+Subject: Test
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+Content-Transfer-Encoding: 8bit
+Date:
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain
+Content-Transfer-Encoding: 8bit
+
+¡Ay, caramba!
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; name="attachment.txt"
+Content-Description: attachment.txt
+Content-Disposition: attachment; filename="attachment.txt"
+Content-Transfer-Encoding: 8bit
+
+8-bit attachment, ¡Ay, caramba!
+
+------- =_aaaaaaaaaa0--
+EOF
+
+test_attachment "${testname}.expected"
+
+
rm -f ${MHMTSCONF} "${MH_TEST_DIR}/attachment.txt"
finish_test
echo 'mhshow-charset-windows-1252: echo "This is a test"' >> "$MH"
# Write message with bogus quoted-printable data.
+start_test 'Write message with bogus quoted-printable data'
msgfile=`mhpath new`
msgnum=`basename $msgfile`
cat > $msgfile <<EOF
EOF
run_prog mhshow $msgnum > $actual 2>&1
-check "$expected" "$actual" : bogus quoted-printable data
+check "$expected" "$actual" 'keep first' : bogus quoted-printable data
+
+start_test 'locale profile component'
+#### Used LC_ALL above, now use locale profile component instead.
+printf "locale: $LC_ALL\n" >> "${MH}"
+unset LC_ALL
+
+run_prog mhshow $msgnum > $actual 2>&1
+check "$expected" "$actual" : locale profile component
+
+
+finish_test
exit $failed