Commit bd228fc3 bd228fc3d1f40f0f230db1d066fb5a330a0c35a9 by Sergey Poznyakoff

mh: set a compatible search path for format files; other minor fixes.

* mh/mh_format.c (builtin_friendly): If personal part is present,
return it.  Otherwise, leave the address untouched.
(builtin_pers): Do not quote the return.
* mh/tests/inc.at: Reflect the above changes.
* mh/tests/scan.at: Likewise.

* mh/mh_list.c (eval_body): Offset each line.
* mh/tests/mhl.at: Test this change.

* mh/mhl.c: Use mh_find_file to resolve the argument to -form.
* mh/repl.c: Likewise.
Same for replgroupcomps, mhl.repl and -filter.

* mh/mhl.repl: New file.
* mh/mhl.usenet: New file.
* mh/Makefile.am (mhlib_DATA, EXTRA_DIST): Add new files.
1 parent 3f323ca9
......@@ -98,9 +98,9 @@ BUILT_SOURCES= \
MAINTAINERCLEANFILES=$(BUILT_SOURCES)
mhlib_DATA = components replcomps replgroupcomps mhl.format mhl.forward\
$(LISPSRC)
mhl.repl mhl.usenet $(LISPSRC)
EXTRA_DIST = components replcomps replgroupcomps mhl.format mhl.forward\
mailutils-mh.eli mh_fmtgram.y pick.y mh_alias.y mh_alias.l
mhl.repl mhl.usenet mailutils-mh.eli mh_fmtgram.y pick.y mh_alias.y mh_alias.l
DISTCLEANFILES = mailutils-mh.el
SUFFIXES = .eli .el
......
......@@ -1583,7 +1583,20 @@ builtin_proper (struct mh_machine *mach)
static void
builtin_friendly (struct mh_machine *mach)
{
/*FIXME: noop*/
mu_address_t addr;
const char *str;
int rc;
rc = mu_address_create (&addr, strobj_ptr (&mach->arg_str));
if (rc)
return;
if (mu_address_sget_personal (addr, 1, &str) == 0 && str)
{
strobj_free (&mach->arg_str);
strobj_create (&mach->arg_str, str);
}
mu_address_destroy (&addr);
}
/* addr addr string mbox@host or host!mbox rendering*/
......@@ -1618,12 +1631,7 @@ builtin_pers (struct mh_machine *mach)
return;
if (mu_address_sget_personal (addr, 1, &str) == 0 && str)
{
char *p;
mu_asprintf (&p, "\"%s\"", str);
strobj_create (&mach->arg_str, p);
free (p);
}
strobj_create (&mach->arg_str, str);
mu_address_destroy (&addr);
}
......
......@@ -700,8 +700,6 @@ eval_body (struct eval_env *env)
if (env->bvar[B_DISABLE_BODY])
return 0;
print_component_name (env);
env->prefix = env->svar[S_COMPONENT];
mu_message_get_body (env->msg, &body);
......@@ -728,7 +726,7 @@ eval_body (struct eval_env *env)
while (mu_stream_readline (input, buf, sizeof buf, &n) == 0
&& n > 0)
{
buf[n] = 0;
goto_offset (env, env->ivar[I_OFFSET]);
print (env, buf, 0);
nl = buf[n-1] == '\n';
}
......
......@@ -99,7 +99,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
break;
case ARG_FORM:
formfile = arg;
mh_find_file (arg, &formfile);
break;
case ARG_WIDTH:
......
; Default format file for GNU repl
;
; GNU Mailutils -- a suite of utilities for electronic mail
; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
;
:
body:nocomponent,offset=9
; USENET-style format file for GNU repl
;
; GNU Mailutils -- a suite of utilities for electronic mail
; Copyright (C) 2003, 2010 Free Software Foundation, Inc.
; Distributed under GPLv3+. See <http://gnu.org/licenses/gpl.html>.
;
:
message-id:nocomponent,nonewline,formatfield="In message %{text}, "
from:nocomponent,formatfield="%(friendly{text}) writes:"
body:component=">",overflowtext=">",overflowoffset=0
......@@ -55,6 +55,7 @@ static struct argp_option options[] = {
{"form", ARG_FORM, N_("FILE"), 0, N_("read format from given file")},
{"format", ARG_FORMAT, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("include a copy of the message being replied; the message will be processed using either the default filter \"mhl.reply\", or the filter specified by --filter option") },
{"noformat", ARG_NOFORMAT, 0, OPTION_HIDDEN, "" },
{"inplace", ARG_INPLACE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("* annotate the message in place")},
{"query", ARG_QUERY, N_("BOOL"), OPTION_ARG_OPTIONAL,
......@@ -178,17 +179,15 @@ opt_handler (int key, char *arg, struct argp_state *state)
case ARG_FORM:
free (format_str);
format_str = NULL;
s = mh_expand_name (MHLIBDIR, arg, 0);
mh_read_formfile (s, &format_str);
free (s);
if (mh_read_formfile (arg, &format_str))
exit (1);
break;
case ARG_GROUP:
if (is_true (arg))
{
s = mh_expand_name (MHLIBDIR, "replgroupcomps", 0);
mh_read_formfile (s, &format_str);
free (s);
if (mh_read_formfile ("replgroupcomps", &format_str))
exit (1);
rcpt_mask |= RCPT_ALL;
}
else
......@@ -229,18 +228,19 @@ opt_handler (int key, char *arg, struct argp_state *state)
break;
case ARG_FILTER:
mhl_filter = arg;
mh_find_file (arg, &mhl_filter);
break;
case ARG_FORMAT:
if (is_true (arg))
{
if (!mhl_filter)
mhl_filter = mh_expand_name (MHLIBDIR, "mhl.repl", 0);
}
mh_find_file ("mhl.repl", &mhl_filter);
else
mhl_filter = NULL;
break;
case ARG_NOFORMAT:
mhl_filter = NULL;
break;
case ARG_FCC:
if (!has_fcc)
......
......@@ -22,8 +22,8 @@ inc -notruncate -file ./mbox1 | sed 's/ *$//'
cmp $abs_top_srcdir/testsuite/spool/mbox1 mbox1
],
[0],
[ 1+ 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 1+ 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -36,8 +36,8 @@ echo "Next"
inc -truncate -file ./mbox1 | sed 's/ *$//'
],
[0],
[ 1+ 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 1+ 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -50,8 +50,8 @@ mkdir Mail/new
inc +new -file ./mbox1 | sed 's/ *$//'
],
[0],
[ 1+ 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 1+ 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -63,8 +63,8 @@ MUT_MBCOPY([$abs_top_srcdir/testsuite/spool/mbox1])
inc -changecur -file ./mbox1 | sed 's/ *$//'
],
[0],
[ 6+ 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
7 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 6+ 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
7 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
8 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
9 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
10 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -78,8 +78,8 @@ inc -nochangecur -file ./mbox1 | sed 's/ *$//'
grep ^cur: Mail/inbox/.mh_sequences
],
[0],
[ 6 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
7 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 6 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
7 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
8 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
9 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
10 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......
......@@ -34,5 +34,28 @@ X-Envelope-Sender: alice@wonder.land
I don't see any wine
])
MH_CHECK([mhl repl],[mhl01 mhl.repl],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
mhl -form $abs_top_srcdir/mh/mhl.repl Mail/inbox/15
],
[0],
[
Not the same thing a bit! You might just
as well say that "I see what I eat" is the same thing as "I eat
what I see"!
])
MH_CHECK([mhl usenet],[mhl02 mhl.usenet],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
mhl -form $abs_top_srcdir/mh/mhl.usenet Mail/inbox/15
],
[0],
[
In message <200207292200.3315@wonder.land>, Hatter writes:
>Not the same thing a bit! You might just
>as well say that "I see what I eat" is the same thing as "I eat
>what I see"!
])
m4_popdef[MH_KEYWORDS])
# End of mhl.at
......
......@@ -22,8 +22,8 @@ echo "Current-Folder: inbox" > Mail/context
scan | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -34,8 +34,8 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
scan +inbox | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
[ 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
......@@ -43,7 +43,7 @@ scan +inbox | sed 's/ *$//'
MH_CHECK([scan -format],[scan02 scan-format],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail])
scan +mbox1 -format '%4(msg) %(decode(friendly{from})) - %(decode(friendly{to}))'
scan +mbox1 -format '%4(msg) %{from} - %{to}'
],
[0],
[ 1 Foo Bar <foobar@nonexistent.net> - Bar <bar@dontmailme.org>
......@@ -59,11 +59,11 @@ echo '%4(msg) %(decode(friendly{from})) - %(decode(friendly{to}))' > formfile
scan +mbox1 -form formfile
],
[0],
[ 1 Foo Bar <foobar@nonexistent.net> - Bar <bar@dontmailme.org>
2 Bar <bar@dontmailme.org> - Foo Bar <foobar@nonexistent.net>
3 Sergey Poznyakoff <gray@example.net> - Foo Bar <foobar@nonexistent.net>
4 Sergey Poznyakoff <gray@example.net> - Foo Bar <foobar@nonexistent.net>
5 Sergey Poznyakoff <gray@example.net> - Foo Bar <foobar@nonexistent.net>
[ 1 Foo Bar - Bar
2 Bar - Foo Bar
3 Sergey Poznyakoff - Foo Bar
4 Sergey Poznyakoff - Foo Bar
5 Sergey Poznyakoff - Foo Bar
])
MH_CHECK([scan -reverse],[scan04 scan-reverse],[
......@@ -74,8 +74,8 @@ scan +mbox1 -reverse | sed 's/ *$//'
[ 5 07/13 Sergey Poznyakoff Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
4 07/13 Sergey Poznyakoff Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
3 07/13 Sergey Poznyakoff Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
2 12/28 Bar <bar@dontmail Re: Jabberwocky<<It seems very pretty, but it's
1 12/28 Foo Bar <foobar@n Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
])
m4_popdef[MH_KEYWORDS])
......