Commit e34d8c16 e34d8c168f9031dbfc2441006e0eb24182ef4389 by Sergey Poznyakoff

mh: fix msgset parser and some more comp compatibility issues; provide testsuite for comp.

* mh/Makefile.am (bin_PROGRAMS): Add mhseq.
* mh/comp.c (main): Rewrite to fix compatibility issues.
* mh/mh.h (MH_MSGSET_UID): New define.
(mh_msgset_t) <flags,size>: New members.
* mh/mh_init.c (mh_draft_message): Bugfix: convert msgset to UIDs.
* mh/mh_msgset.c: Rewrite from scratch.

* mh/tests/comp.at: New file.
* mh/tests/mhseq.at: New file.
* mh/tests/Makefile.am (TESTSUITE_AT): Add comp.at, mhseq.at.
* mh/tests/testsuite.at: Include comp.at and mhseq.at.

* libmailutils/property/mhprop.c (_mh_prop_read_stream): Minor fix.
Do remove empty lines.
* mh/mh_whatnow.c (_whatnow): Detect EOF.
(call_send): Quit after successful send.
1 parent e6927c46
...@@ -113,7 +113,7 @@ _mh_prop_read_stream (mu_header_t *phdr, mu_stream_t stream) ...@@ -113,7 +113,7 @@ _mh_prop_read_stream (mu_header_t *phdr, mu_stream_t stream)
113 argv[1] = "#"; 113 argv[1] = "#";
114 argv[2] = "-r"; 114 argv[2] = "-r";
115 argv[3] = NULL; 115 argv[3] = NULL;
116 rc = mu_filter_create_args (&flt, stream, argv[0], 2, argv, 116 rc = mu_filter_create_args (&flt, stream, argv[0], 3, argv,
117 MU_FILTER_DECODE, MU_STREAM_READ); 117 MU_FILTER_DECODE, MU_STREAM_READ);
118 if (rc) 118 if (rc)
119 { 119 {
......
...@@ -23,6 +23,7 @@ mh_alias_lex.c ...@@ -23,6 +23,7 @@ mh_alias_lex.c
23 mh_fmtgram.c 23 mh_fmtgram.c
24 mhl 24 mhl
25 mhn 25 mhn
26 mhseq
26 mhparam 27 mhparam
27 mhpath 28 mhpath
28 pick 29 pick
......
...@@ -33,6 +33,7 @@ bin_PROGRAMS = \ ...@@ -33,6 +33,7 @@ bin_PROGRAMS = \
33 mhn\ 33 mhn\
34 mhparam\ 34 mhparam\
35 mhpath\ 35 mhpath\
36 mhseq\
36 pick\ 37 pick\
37 prompter\ 38 prompter\
38 refile\ 39 refile\
......
...@@ -80,6 +80,7 @@ static int build_only = 0; /* --build flag */ ...@@ -80,6 +80,7 @@ static int build_only = 0; /* --build flag */
80 static int use_draft = 0; /* --use flag */ 80 static int use_draft = 0; /* --use flag */
81 static char *draftmessage = "new"; 81 static char *draftmessage = "new";
82 static const char *draftfolder = NULL; 82 static const char *draftfolder = NULL;
83 static int folder_set; /* Folder is set on the command line */
83 84
84 static error_t 85 static error_t
85 opt_handler (int key, char *arg, struct argp_state *state) 86 opt_handler (int key, char *arg, struct argp_state *state)
...@@ -87,8 +88,7 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -87,8 +88,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
87 switch (key) 88 switch (key)
88 { 89 {
89 case ARGP_KEY_INIT: 90 case ARGP_KEY_INIT:
90 draftfolder = mh_global_profile_get ("Draft-Folder", 91 draftfolder = mh_global_profile_get ("Draft-Folder", NULL);
91 mu_folder_directory ());
92 whatnowproc = mh_global_profile_get ("whatnowproc", NULL); 92 whatnowproc = mh_global_profile_get ("whatnowproc", NULL);
93 break; 93 break;
94 94
...@@ -106,6 +106,7 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -106,6 +106,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
106 106
107 case ARG_FOLDER: 107 case ARG_FOLDER:
108 mh_set_current_folder (arg); 108 mh_set_current_folder (arg);
109 folder_set = 1;
109 break; 110 break;
110 111
111 case ARG_FORM: 112 case ARG_FORM:
...@@ -126,7 +127,7 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -126,7 +127,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
126 break; 127 break;
127 128
128 case ARG_FILE: 129 case ARG_FILE:
129 wh_env.draftfile = mh_expand_name (NULL, arg, 0); 130 wh_env.file = mh_expand_name (NULL, arg, 0);
130 break; 131 break;
131 132
132 case ARG_NODRAFTFOLDER: 133 case ARG_NODRAFTFOLDER:
...@@ -197,7 +198,7 @@ main (int argc, char **argv) ...@@ -197,7 +198,7 @@ main (int argc, char **argv)
197 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, 198 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
198 opt_handler, NULL, &index); 199 opt_handler, NULL, &index);
199 200
200 if (wh_env.draftfile) 201 if (wh_env.file)
201 { 202 {
202 if (build_only) 203 if (build_only)
203 { 204 {
...@@ -205,68 +206,90 @@ main (int argc, char **argv) ...@@ -205,68 +206,90 @@ main (int argc, char **argv)
205 exit (1); 206 exit (1);
206 } 207 }
207 } 208 }
209 else if (folder_set)
210 {
211 wh_env.file = mh_expand_name (NULL, "draft", 0);
212 }
208 else 213 else
209 { 214 {
210 if (build_only || !draftfolder) 215 if (build_only || !draftfolder)
211 wh_env.file = mh_expand_name (NULL, "draft", 0); 216 {
217 switch (argc - index)
218 {
219 case 0:
220 wh_env.file = mh_expand_name (NULL, "draft", 0);
221 break;
222
223 case 1:
224 wh_env.file = mh_expand_name (NULL, argv[index], 0);
225 break;
226
227 default:
228 mu_error (_("only one message at a time!"));
229 return 1;
230 }
231 }
212 else if (draftfolder) 232 else if (draftfolder)
213 { 233 {
214 /* Comp accepts a `file', and it will, if given 234 /* Comp accepts a `file', and it will, if given
215 `-draftfolder +folder' treat this arguments as `msg'. */ 235 `-draftfolder +folder' treat this arguments as `msg'. */
216 if (index < argc) 236 if (use_draft || index < argc)
217 { 237 {
218 mh_msgset_t msgset; 238 mh_msgset_t msgset;
219 mu_mailbox_t mbox; 239 mu_mailbox_t mbox;
220 240
221 mbox = mh_open_folder (draftfolder, 1); 241 mbox = mh_open_folder (draftfolder, 1);
222 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, 242 mh_msgset_parse (mbox, &msgset,
223 "new"); 243 argc - index, argv + index,
244 use_draft ? "cur" : "new");
224 mu_mailbox_destroy (&mbox); 245 mu_mailbox_destroy (&mbox);
225 if (msgset.count != 1) 246 if (msgset.count != 1)
226 { 247 {
227 mu_error (_("only one message at a time!")); 248 mu_error (_("only one message at a time!"));
228 return 1; 249 return 1;
229 } 250 }
251 mh_msgset_uids (mbox, &msgset);
230 draftmessage = mu_umaxtostr (0, msgset.list[0]); 252 draftmessage = mu_umaxtostr (0, msgset.list[0]);
231 mh_msgset_free (&msgset); 253 mh_msgset_free (&msgset);
232 index = argc;
233 } 254 }
234 if (mh_draft_message (draftfolder, draftmessage, 255 if (mh_draft_message (draftfolder, draftmessage,
235 &wh_env.file)) 256 &wh_env.file))
236 return 1; 257 return 1;
237 } 258 }
238 wh_env.draftfile = wh_env.file;
239 } 259 }
240 260 wh_env.draftfile = wh_env.file;
241 switch (check_draft_disposition (&wh_env, use_draft))
242 {
243 case DISP_QUIT:
244 exit (0);
245 261
246 case DISP_USE: 262 if (folder_set && index < argc)
247 break; 263 {
248 264 mh_msgset_t msgset;
249 case DISP_REPLACE: 265 mu_mailbox_t mbox;
250 unlink (wh_env.draftfile); 266
251 267 mbox = mh_open_folder (mh_current_folder (), 0);
252 if (index < argc) 268 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
269 if (msgset.count != 1)
253 { 270 {
254 mh_msgset_t msgset; 271 mu_error (_("only one message at a time!"));
255 mu_mailbox_t mbox; 272 return 1;
273 }
274 unlink (wh_env.file);
275 copy_message (mbox, msgset.list[0], wh_env.file);
276 mu_mailbox_destroy (&mbox);
277 mh_msgset_free (&msgset);
278 }
279 else
280 {
281 switch (check_draft_disposition (&wh_env, use_draft))
282 {
283 case DISP_QUIT:
284 exit (0);
285
286 case DISP_USE:
287 break;
256 288
257 mbox = mh_open_folder (mh_current_folder (), 0); 289 case DISP_REPLACE:
258 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur"); 290 unlink (wh_env.draftfile);
259 if (msgset.count != 1) 291 mh_comp_draft (formfile, "components", wh_env.file);
260 {
261 mu_error (_("only one message at a time!"));
262 return 1;
263 }
264 copy_message (mbox, msgset.list[0], wh_env.file);
265 mu_mailbox_destroy (&mbox);
266 mh_msgset_free (&msgset);
267 } 292 }
268 else
269 mh_comp_draft (formfile, "components", wh_env.file);
270 } 293 }
271 294
272 /* Exit immediately if --build is given */ 295 /* Exit immediately if --build is given */
......
...@@ -195,10 +195,14 @@ typedef struct ...@@ -195,10 +195,14 @@ typedef struct
195 mu_header_t header; 195 mu_header_t header;
196 } mh_context_t; 196 } mh_context_t;
197 197
198 #define MH_MSGSET_UID 0x01
199
198 typedef struct 200 typedef struct
199 { 201 {
200 size_t count; 202 int flags;
201 size_t *list; 203 size_t *list;
204 size_t count;
205 size_t size;
202 } mh_msgset_t; 206 } mh_msgset_t;
203 207
204 typedef void (*mh_iterator_fp) (mu_mailbox_t mbox, mu_message_t msg, 208 typedef void (*mh_iterator_fp) (mu_mailbox_t mbox, mu_message_t msg,
...@@ -300,8 +304,8 @@ int mh_message_number (mu_message_t msg, size_t *pnum); ...@@ -300,8 +304,8 @@ int mh_message_number (mu_message_t msg, size_t *pnum);
300 304
301 mu_mailbox_t mh_open_folder (const char *folder, int create); 305 mu_mailbox_t mh_open_folder (const char *folder, int create);
302 306
303 int mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset, 307 void mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset,
304 int argc, char **argv, char *def); 308 int argc, char **argv, char *def);
305 int mh_msgset_member (mh_msgset_t *msgset, size_t num); 309 int mh_msgset_member (mh_msgset_t *msgset, size_t num);
306 void mh_msgset_reverse (mh_msgset_t *msgset); 310 void mh_msgset_reverse (mh_msgset_t *msgset);
307 void mh_msgset_negate (mu_mailbox_t mbox, mh_msgset_t *msgset); 311 void mh_msgset_negate (mu_mailbox_t mbox, mh_msgset_t *msgset);
......
...@@ -998,14 +998,14 @@ mh_draft_message (const char *name, const char *msgspec, char **pname) ...@@ -998,14 +998,14 @@ mh_draft_message (const char *name, const char *msgspec, char **pname)
998 998
999 argv[0] = (char*) msgspec; 999 argv[0] = (char*) msgspec;
1000 argv[1] = NULL; 1000 argv[1] = NULL;
1001 rc = mh_msgset_parse (mbox, &msgset, 1, argv, "cur"); 1001 mh_msgset_parse (mbox, &msgset, 1, argv, "cur");
1002 if (rc) 1002 if (msgset.count > 1)
1003 mu_error (_("invalid message number: %s"), msgspec);
1004 else if (msgset.count > 1)
1005 mu_error (_("only one message at a time!")); 1003 mu_error (_("only one message at a time!"));
1006 else 1004 else
1007 uid = msgset.list[0]; 1005 {
1008 1006 mh_msgset_uids (mbox, &msgset);
1007 uid = msgset.list[0];
1008 }
1009 mh_msgset_free (&msgset); 1009 mh_msgset_free (&msgset);
1010 } 1010 }
1011 1011
......
...@@ -346,18 +346,21 @@ _whatnow (struct mh_whatnow_env *wh, struct action_tab *tab) ...@@ -346,18 +346,21 @@ _whatnow (struct mh_whatnow_env *wh, struct action_tab *tab)
346 346
347 do 347 do
348 { 348 {
349 size_t n;
349 handler_fp fun; 350 handler_fp fun;
350 351
351 printf ("%s ", wh->prompt); 352 printf ("%s ", wh->prompt);
352 fflush (stdout); 353 fflush (stdout);
353 rc = mu_stream_getline (in, &line, &size, NULL); 354 rc = mu_stream_getline (in, &line, &size, &n);
354 if (rc) 355 if (rc)
355 { 356 {
356 mu_error (_("cannot read input stream: %s"), mu_strerror (rc)); 357 mu_error (_("cannot read input stream: %s"), mu_strerror (rc));
357 status = 1; 358 status = 1;
358 break; 359 break;
359 } 360 }
360 361 if (n == 0)
362 break;
363
361 ws.ws_comment = "#"; 364 ws.ws_comment = "#";
362 rc = mu_wordsplit (line, &ws, wsflags); 365 rc = mu_wordsplit (line, &ws, wsflags);
363 if (rc) 366 if (rc)
...@@ -462,7 +465,10 @@ static int ...@@ -462,7 +465,10 @@ static int
462 call_send (struct mh_whatnow_env *wh, int argc, char **argv, int *status) 465 call_send (struct mh_whatnow_env *wh, int argc, char **argv, int *status)
463 { 466 {
464 if (invoke ("sendproc", MHBINDIR "/send", argc, argv, wh->file, NULL) == 0) 467 if (invoke ("sendproc", MHBINDIR "/send", argc, argv, wh->file, NULL) == 0)
465 annotate (wh); 468 {
469 annotate (wh);
470 return 1;
471 }
466 return 0; 472 return 0;
467 } 473 }
468 474
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2010 Free Software Foundation, Inc.
3
4 GNU Mailutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 GNU Mailutils is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
16
17 /* MH mhparam command */
18
19 #include <mh.h>
20
21 static char doc[] = N_("GNU MH mhseq")"\v"
22 N_("Use -help to obtain the list of traditional MH options.");
23 static char args_doc[] = N_("[SEQUENCE]");
24
25 static struct argp_option options[] = {
26 {"folder", ARG_FOLDER, N_("FOLDER"), 0,
27 N_("specify the folder to use")},
28 { "uids", 'u', NULL, 0,
29 N_("show message UIDs (default)")},
30 { "numbers", 'n', NULL, 0,
31 N_("show message numbers") },
32 { NULL }
33 };
34
35 /* Traditional MH options */
36 struct mh_option mh_option[] = {
37 { "uid" },
38 { NULL }
39 };
40
41 static int uid_option = 1;
42
43 static error_t
44 opt_handler (int key, char *arg, struct argp_state *state)
45 {
46 switch (key)
47 {
48 case ARG_FOLDER:
49 mh_set_current_folder (arg);
50 break;
51
52 case 'n':
53 uid_option = 0;
54 break;
55
56 case 'u':
57 uid_option = 1;
58 break;
59
60 default:
61 return ARGP_ERR_UNKNOWN;
62 }
63 return 0;
64 }
65
66 int
67 main (int argc, char **argv)
68 {
69 int index;
70 mu_mailbox_t mbox;
71 mh_msgset_t msgset;
72 size_t i;
73
74 /* Native Language Support */
75 MU_APP_INIT_NLS ();
76
77 mh_argp_init ();
78 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
79 opt_handler, NULL, &index);
80
81 argc -= index;
82 argv += index;
83 mbox = mh_open_folder (mh_current_folder (), 0);
84
85 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
86 if (uid_option)
87 mh_msgset_uids (mbox, &msgset);
88
89 for (i = 0; i < msgset.count; i++)
90 printf ("%lu\n", (unsigned long) msgset.list[i]);
91 return 0;
92 }
93
94
...@@ -42,6 +42,7 @@ TESTSUITE_AT = \ ...@@ -42,6 +42,7 @@ TESTSUITE_AT = \
42 ali.at\ 42 ali.at\
43 anno.at\ 43 anno.at\
44 burst.at\ 44 burst.at\
45 comp.at\
45 folder.at\ 46 folder.at\
46 inc.at\ 47 inc.at\
47 install-mh.at\ 48 install-mh.at\
...@@ -49,6 +50,7 @@ TESTSUITE_AT = \ ...@@ -49,6 +50,7 @@ TESTSUITE_AT = \
49 mhl.at\ 50 mhl.at\
50 mhparam.at\ 51 mhparam.at\
51 mhpath.at\ 52 mhpath.at\
53 mhseq.at\
52 pick.at\ 54 pick.at\
53 scan.at\ 55 scan.at\
54 refile.at\ 56 refile.at\
......
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 m4_pushdef([MH_KEYWORDS],[comp])
18 m4_pushdef([compcmd],[comp dnl
19 -form $abs_top_srcdir/mh/components dnl
20 -editor $abs_top_srcdir/mh/tests/mhed])
21
22 MH_CHECK([comp -file],[comp00 comp-file],[
23 dir=`pwd`
24 echo quit | compcmd -file ./infile | sed "s|$dir/*||;s| *$||"
25 cat infile
26 ],
27 [0],
28 [-- Editor invocation: ./infile
29 -- Input file:
30 To:
31 cc:
32 Subject:
33 --------
34 -- Input file end
35 What now? draft left on "./infile".
36 To:
37 cc:
38 Subject:
39 --------
40 Seen by mhed
41 ])
42
43 MH_CHECK([comp -file (del)],[comp01 comp-file_del],[
44 dir=`pwd`
45 echo 'quit -delete' | compcmd -file ./infile | sed "s|$dir/*||;s| *$||"
46 ],
47 [0],
48 [-- Editor invocation: ./infile
49 -- Input file:
50 To:
51 cc:
52 Subject:
53 --------
54 -- Input file end
55 What now?])
56
57 MH_CHECK([comp file],[comp02 comp_file],[
58 echo 'quit' | compcmd file | sed "s|$dir/*||;s| *$||"
59 cat Mail/file
60 ],
61 [0],
62 [-- Editor invocation: Mail/file
63 -- Input file:
64 To:
65 cc:
66 Subject:
67 --------
68 -- Input file end
69 What now? draft left on "Mail/file".
70 To:
71 cc:
72 Subject:
73 --------
74 Seen by mhed
75 ])
76
77 MH_CHECK([comp -use file],[comp03 comp-use_file],[
78 AT_DATA([Mail/file],[From: gray
79 To: root
80 Subject: test input
81
82 message body
83 ])
84
85 echo 'quit' | compcmd -use file | sed "s|$dir/*||;s| *$||"
86 cat Mail/file
87 ],
88 [0],
89 [-- Editor invocation: Mail/file
90 -- Input file:
91 From: gray
92 To: root
93 Subject: test input
94
95 message body
96 -- Input file end
97 What now? draft left on "Mail/file".
98 From: gray
99 To: root
100 Subject: test input
101
102 message body
103 Seen by mhed
104 ])
105
106 MH_CHECK([comp +folder msg],[comp04 comp+folder_msg],[
107 mkdir Mail/inbox
108 AT_DATA([Mail/inbox/1],[From: gray
109 To: root
110 Subject: test input
111
112 message body
113 ])
114
115 echo 'quit' | compcmd +inbox 1 | sed "s|$dir/*||;s| *$||"
116 echo Mail/draft
117 cat Mail/draft
118 echo Message
119 cat Mail/inbox/1
120 ],
121 [0],
122 [-- Editor invocation: Mail/draft
123 -- Input file:
124 From: gray
125 To: root
126 Subject: test input
127
128 message body
129 -- Input file end
130 What now? draft left on "Mail/draft".
131 Mail/draft
132 From: gray
133 To: root
134 Subject: test input
135
136 message body
137 Seen by mhed
138 Message
139 From: gray
140 To: root
141 Subject: test input
142
143 message body
144 ])
145
146 m4_popdef([compcmd])
147 m4_popdef([MH_KEYWORDS])
148
1 #! /bin/sh
2
3 echo "-- Editor invocation:" $*
4 echo "-- Input file: "
5 cat $1
6 echo "-- Input file end"
7 echo "Seen by mhed" >> $1
8 exit 0
1 # This file is part of GNU Mailutils. -*- Autotest -*-
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 m4_pushdef([MH_KEYWORDS],[mhseq mh-sequences])
18
19 dnl ---------------------------------------------------------------
20
21 MH_CHECK([mhseq: existing message number],[mhseq00],[
22 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
23 mhseq 1
24 ],
25 [0],
26 [1
27 ])
28
29 MH_CHECK([mhseq: not existing message number],[mhseq01],[
30 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
31 mhseq 100
32 ],
33 [1],
34 [],
35 dnl FIXME: See FIXME 3 in mhpath.at
36 [mhseq: message 100 does not exist
37 ])
38
39 MH_CHECK([mhseq: contiguous message range],[mhseq02],[
40 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
41 mhseq 2-5
42 ],
43 [0],
44 [2
45 3
46 4
47 5
48 ])
49
50 MH_CHECK([mhseq: reversed contiguous message range],[mhseq03],[
51 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
52 mhseq 5-2
53 ],
54 [0],
55 [2
56 3
57 4
58 5
59 ])
60
61 MH_CHECK([mhseq: reversed non-contiguous message range],[mhseq04],[
62 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
63 rm Mail/inbox/3 Mail/inbox/4
64 mhseq 5-2
65 ],
66 [0],
67 [2
68 5
69 ])
70
71 MH_CHECK([mhseq: message range (left fixup)],[mhseq05],[
72 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
73 rm Mail/inbox/1 Mail/inbox/2
74 mhseq 1-5
75 ],
76 [0],
77 [3
78 4
79 5
80 ])
81
82 MH_CHECK([mhseq: message range (right fixup)],[mhseq06],[
83 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
84 rm Mail/inbox/4 Mail/inbox/5
85 mhseq 1-5
86 ],
87 [0],
88 [1
89 2
90 3
91 ])
92
93 MH_CHECK([mhseq: message range (both fixups)],[mhseq07],[
94 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
95 rm Mail/inbox/1 Mail/inbox/5
96 mhseq 1-5
97 ],
98 [0],
99 [2
100 3
101 4
102 ])
103
104 MH_CHECK([mhseq: non-existent message range (left)],[mhseq08],[
105 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
106 rm Mail/inbox/1 Mail/inbox/2 Mail/inbox/3
107 mhseq 1-2
108 ],
109 [1],
110 [],
111 [mhseq: no messages in range 1-2
112 ])
113
114 MH_CHECK([mhseq: non-existent message range (right)],[mhseq09],[
115 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
116 mhseq 6-10
117 ],
118 [1],
119 [],
120 [mhseq: no messages in range 6-10
121 ])
122
123 MH_CHECK([mhseq: message set addition],[mhseq10],[
124 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
125 mhseq 5 8-10 15-20
126 ],
127 [0],
128 [5
129 8
130 9
131 10
132 15
133 16
134 17
135 18
136 19
137 20
138 ])
139
140 MH_CHECK([mhseq: message set optimization],[mhseq11],[
141 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
142 rm Mail/inbox/17 Mail/inbox/19
143 mhseq 5 1-10 15-20
144 ],
145 [0],
146 [1
147 2
148 3
149 4
150 5
151 6
152 7
153 8
154 9
155 10
156 15
157 16
158 18
159 20
160 ])
161
162 MH_CHECK([mhseq: counted range (positive)],[mhseq12],[
163 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
164 mhseq 10:4
165 ],
166 [0],
167 [10
168 11
169 12
170 13
171 ])
172
173 MH_CHECK([mhseq: non-contiguous counted range (positive)],[mhseq13],[
174 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
175 rm Mail/inbox/12 Mail/inbox/14
176 mhseq 10:4
177 ],
178 [0],
179 [10
180 11
181 13
182 15
183 ])
184
185 MH_CHECK([mhseq: counted range (positive, left fixup)],[mhseq14],[
186 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
187 rm Mail/inbox/1 Mail/inbox/2
188 mhseq 1:3
189 ],
190 [0],
191 [3
192 4
193 5
194 ])
195
196 MH_CHECK([mhseq: counted range (positive, right fixup)],[mhseq15],[
197 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
198 mhseq 2:10
199 ],
200 [0],
201 [2
202 3
203 4
204 5
205 ])
206
207 MH_CHECK([mhseq: invalid counted range (negative)],[mhseq16],[
208 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
209 rm Mail/inbox/1 Mail/inbox/2
210 mhseq 10:2
211 ],
212 [1],
213 [],
214 [mhseq: no messages in range 10:2
215 ])
216
217 MH_CHECK([mhseq: counted range (negative)],[mhseq17],[
218 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
219 mhseq 10:-4
220 ],
221 [0],
222 [7
223 8
224 9
225 10
226 ])
227
228 MH_CHECK([mhseq: non-contiguous counted range (negative)],[mhseq18],[
229 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox])
230 rm Mail/inbox/8 Mail/inbox/6
231 mhseq 10:-4
232 ],
233 [0],
234 [5
235 7
236 9
237 10
238 ])
239
240 MH_CHECK([mhseq: counted range (negative, left fixup)],[mhseq19],[
241 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
242 rm Mail/inbox/1 Mail/inbox/2
243 mhseq 4:-30
244 ],
245 [0],
246 [3
247 4
248 ])
249
250 MH_CHECK([mhseq: counted range (negative, right fixup)],[mhseq20],[
251 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
252 rm Mail/inbox/1 Mail/inbox/2
253 mhseq 4:30
254 ],
255 [0],
256 [4
257 5
258 ])
259
260 MH_CHECK([mhseq: invalid counted range (negative)],[mhseq21],[
261 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
262 rm Mail/inbox/1 Mail/inbox/2
263 mhseq 1:-30
264 ],
265 [1],
266 [],
267 [mhseq: no messages in range 1:-30
268 ])
269
270 MH_CHECK([mhseq: cur],[mhseq22 cur],[
271 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
272 echo "cur: 3" > Mail/inbox/.mh_sequences
273 mhseq cur
274 ],
275 [0],
276 [3
277 ])
278
279 MH_CHECK([mhseq: cur:n -- default direction],[mhseq23 cur:n],[
280 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
281 echo "cur: 3" > Mail/inbox/.mh_sequences
282 mhseq cur:2
283 ],
284 [0],
285 [3
286 4
287 ])
288
289 MH_CHECK([mhseq: cur:n -- explicit dir (negative)],[mhseq24 cur:n cur:n-],[
290 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
291 echo "cur: 3" > Mail/inbox/.mh_sequences
292 mhseq cur:-2
293 ],
294 [0],
295 [2
296 3
297 ])
298
299 MH_CHECK([mhseq: cur:n -- explicit dir (positive)],[mhseq25 cur:n cur:n+],[
300 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
301 echo "cur: 3" > Mail/inbox/.mh_sequences
302 mhseq cur:+2
303 ],
304 [0],
305 [3
306 4
307 ])
308
309 MH_CHECK([mhseq: next],[mhseq26 next],[
310 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
311 echo "cur: 3" > Mail/inbox/.mh_sequences
312 rm Mail/inbox/4
313 mhseq next
314 ],
315 [0],
316 [5
317 ])
318
319 MH_CHECK([mhseq: next:n -- default direction],[mhseq27 next:n],[
320 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
321 echo "cur: 3" > Mail/inbox/.mh_sequences
322 mhseq next:2
323 ],
324 [0],
325 [4
326 5
327 ])
328
329 MH_CHECK([mhseq: prev],[mhseq28 prev],[
330 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
331 echo "cur: 3" > Mail/inbox/.mh_sequences
332 rm Mail/inbox/2
333 mhseq prev
334 ],
335 [0],
336 [1
337 ])
338
339 MH_CHECK([mhseq: prev:n -- default direction],[mhseq29 prev:n],[
340 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
341 echo "cur: 3" > Mail/inbox/.mh_sequences
342 mhseq prev:2
343 ],
344 [0],
345 [1
346 2
347 ])
348
349 MH_CHECK([mhseq: first],[mhseq30 first],[
350 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
351 rm Mail/inbox/1
352 mhseq first
353 ],
354 [0],
355 [2
356 ])
357
358 MH_CHECK([mhseq: first:n -- default direction],[mhseq31 first:n],[
359 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
360 rm Mail/inbox/1
361 mhseq first:2
362 ],
363 [0],
364 [2
365 3
366 ])
367
368 MH_CHECK([mhseq: last],[mhseq32 last],[
369 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
370 mhseq last
371 ],
372 [0],
373 [5
374 ])
375
376 MH_CHECK([mhseq: last:n -- default direction],[mhseq33 last:n],[
377 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
378 mhseq last:2
379 ],
380 [0],
381 [4
382 5
383 ])
384
385 m4_popdef([MH_KEYWORDS])
386 # End of mhseq.at
...\ No newline at end of file ...\ No newline at end of file
...@@ -42,6 +42,7 @@ AT_CLEANUP ...@@ -42,6 +42,7 @@ AT_CLEANUP
42 AT_INIT 42 AT_INIT
43 43
44 m4_include([install-mh.at]) 44 m4_include([install-mh.at])
45 m4_include([mhseq.at])
45 m4_include([ali.at]) 46 m4_include([ali.at])
46 m4_include([folder.at]) 47 m4_include([folder.at])
47 m4_include([inc.at]) 48 m4_include([inc.at])
...@@ -56,3 +57,4 @@ m4_include([mhl.at]) ...@@ -56,3 +57,4 @@ m4_include([mhl.at])
56 m4_include([anno.at]) 57 m4_include([anno.at])
57 m4_include([pick.at]) 58 m4_include([pick.at])
58 m4_include([burst.at]) 59 m4_include([burst.at])
60 m4_include([comp.at])
......