Commit 34361061 34361061098003122b0ce911a87123f012e79f88 by Sergey Poznyakoff

sortm: update current message number; add testsuite.

* mh/sortm.c (current_num): New variable.
(sort): Keep track of the current message UID.  Store it back to
mailbox if in reorder mode.
(main): Save initial current message UID.  Save global and mailbox
status before exiting.
* mh/mh.h (mh_open_folder): Change last argument name.
* mh_open_folder (mh_open_folder): Change meaning of the 2nd argument:
it contains usual stream flags now.  All uses changed.

* mh/tests/sortm.at: New file.
* mh/tests/testsuite.at: Include sortm.at
* mh/tests/Makefile.am (TESTSUITE_AT): Add sortm.at.
1 parent f5374bc2
...@@ -116,7 +116,7 @@ main (int argc, char **argv) ...@@ -116,7 +116,7 @@ main (int argc, char **argv)
116 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, 116 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
117 opt_handler, NULL, &index); 117 opt_handler, NULL, &index);
118 118
119 mbox = mh_open_folder (mh_current_folder (), 0); 119 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
120 120
121 if (!component) 121 if (!component)
122 { 122 {
......
...@@ -721,7 +721,7 @@ main (int argc, char **argv) ...@@ -721,7 +721,7 @@ main (int argc, char **argv)
721 argv += index; 721 argv += index;
722 722
723 VERBOSE ((_("Opening folder `%s'"), mh_current_folder ())); 723 VERBOSE ((_("Opening folder `%s'"), mh_current_folder ()));
724 mbox = mh_open_folder (mh_current_folder (), 0); 724 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
725 mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); 725 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
726 726
727 if (inplace) 727 if (inplace)
...@@ -729,7 +729,7 @@ main (int argc, char **argv) ...@@ -729,7 +729,7 @@ main (int argc, char **argv)
729 size_t i, count; 729 size_t i, count;
730 730
731 VERBOSE ((_("Opening temporary folder `%s'"), tempfolder)); 731 VERBOSE ((_("Opening temporary folder `%s'"), tempfolder));
732 tmpbox = mh_open_folder (tempfolder, 1); 732 tmpbox = mh_open_folder (tempfolder, MU_STREAM_RDWR|MU_STREAM_CREAT);
733 VERBOSE ((_("Cleaning up temporary folder"))); 733 VERBOSE ((_("Cleaning up temporary folder")));
734 mu_mailbox_messages_count (tmpbox, &count); 734 mu_mailbox_messages_count (tmpbox, &count);
735 for (i = 1; i <= count; i++) 735 for (i = 1; i <= count; i++)
......
...@@ -249,7 +249,8 @@ main (int argc, char **argv) ...@@ -249,7 +249,8 @@ main (int argc, char **argv)
249 mh_msgset_t msgset; 249 mh_msgset_t msgset;
250 mu_mailbox_t mbox; 250 mu_mailbox_t mbox;
251 251
252 mbox = mh_open_folder (draftfolder, 1); 252 mbox = mh_open_folder (draftfolder,
253 MU_STREAM_RDWR|MU_STREAM_CREAT);
253 mh_msgset_parse (mbox, &msgset, 254 mh_msgset_parse (mbox, &msgset,
254 argc - index, argv + index, 255 argc - index, argv + index,
255 use_draft ? "cur" : "new"); 256 use_draft ? "cur" : "new");
...@@ -275,7 +276,7 @@ main (int argc, char **argv) ...@@ -275,7 +276,7 @@ main (int argc, char **argv)
275 mh_msgset_t msgset; 276 mh_msgset_t msgset;
276 mu_mailbox_t mbox; 277 mu_mailbox_t mbox;
277 278
278 mbox = mh_open_folder (mh_current_folder (), 0); 279 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
279 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur"); 280 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
280 if (msgset.count != 1) 281 if (msgset.count != 1)
281 { 282 {
......
...@@ -839,7 +839,7 @@ int ...@@ -839,7 +839,7 @@ int
839 action_pack () 839 action_pack ()
840 { 840 {
841 const char *folder_dir = mh_expand_name (NULL, mh_current_folder (), 0); 841 const char *folder_dir = mh_expand_name (NULL, mh_current_folder (), 0);
842 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), 0); 842 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
843 struct pack_tab *pack_tab; 843 struct pack_tab *pack_tab;
844 size_t i, count, start; 844 size_t i, count, start;
845 int status; 845 int status;
...@@ -917,7 +917,7 @@ action_pack () ...@@ -917,7 +917,7 @@ action_pack ()
917 /* Fix-up sequences */ 917 /* Fix-up sequences */
918 if (!dry_run) 918 if (!dry_run)
919 { 919 {
920 mbox = mh_open_folder (mh_current_folder (), 0); 920 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
921 fd.mbox = mbox; 921 fd.mbox = mbox;
922 fd.folder_dir = folder_dir; 922 fd.folder_dir = folder_dir;
923 fd.pack_tab = pack_tab; 923 fd.pack_tab = pack_tab;
...@@ -967,7 +967,7 @@ main (int argc, char **argv) ...@@ -967,7 +967,7 @@ main (int argc, char **argv)
967 967
968 if (argc - index == 1) 968 if (argc - index == 1)
969 { 969 {
970 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), 0); 970 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
971 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur"); 971 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
972 mh_msgset_current (mbox, &msgset, 0); 972 mh_msgset_current (mbox, &msgset, 0);
973 mh_global_save_state (); 973 mh_global_save_state ();
......
...@@ -503,7 +503,7 @@ main (int argc, char **argv) ...@@ -503,7 +503,7 @@ main (int argc, char **argv)
503 } 503 }
504 else 504 else
505 { 505 {
506 mbox = mh_open_folder (mh_current_folder (), 0); 506 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
507 mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); 507 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
508 } 508 }
509 509
......
...@@ -219,7 +219,7 @@ main (int argc, char **argv) ...@@ -219,7 +219,7 @@ main (int argc, char **argv)
219 exit (1); 219 exit (1);
220 } 220 }
221 221
222 output = mh_open_folder (append_folder, 1); 222 output = mh_open_folder (append_folder, MU_STREAM_RDWR|MU_STREAM_CREAT);
223 if ((rc = mu_mailbox_messages_count (output, &lastmsg)) != 0) 223 if ((rc = mu_mailbox_messages_count (output, &lastmsg)) != 0)
224 { 224 {
225 mu_error (_("cannot read output mailbox: %s"), 225 mu_error (_("cannot read output mailbox: %s"),
......
...@@ -201,7 +201,7 @@ main (int argc, char **argv) ...@@ -201,7 +201,7 @@ main (int argc, char **argv)
201 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, 201 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
202 opt_handler, NULL, &index); 202 opt_handler, NULL, &index);
203 203
204 mbox = mh_open_folder (mh_current_folder (), 0); 204 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
205 mu_mailbox_get_url (mbox, &url); 205 mu_mailbox_get_url (mbox, &url);
206 mbox_dir = mu_url_to_string (url); 206 mbox_dir = mu_url_to_string (url);
207 if (memcmp (mbox_dir, "mh:", 3) == 0) 207 if (memcmp (mbox_dir, "mh:", 3) == 0)
......
...@@ -302,7 +302,7 @@ void mh_audit_close (FILE *fp); ...@@ -302,7 +302,7 @@ void mh_audit_close (FILE *fp);
302 302
303 int mh_message_number (mu_message_t msg, size_t *pnum); 303 int mh_message_number (mu_message_t msg, size_t *pnum);
304 304
305 mu_mailbox_t mh_open_folder (const char *folder, int create); 305 mu_mailbox_t mh_open_folder (const char *folder, int flags);
306 306
307 void mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset, 307 void mh_msgset_parse (mu_mailbox_t mbox, mh_msgset_t *msgset,
308 int argc, char **argv, char *def); 308 int argc, char **argv, char *def);
......
...@@ -443,14 +443,13 @@ mh_message_number (mu_message_t msg, size_t *pnum) ...@@ -443,14 +443,13 @@ mh_message_number (mu_message_t msg, size_t *pnum)
443 } 443 }
444 444
445 mu_mailbox_t 445 mu_mailbox_t
446 mh_open_folder (const char *folder, int create) 446 mh_open_folder (const char *folder, int flags)
447 { 447 {
448 mu_mailbox_t mbox = NULL; 448 mu_mailbox_t mbox = NULL;
449 char *name; 449 char *name;
450 int flags = MU_STREAM_RDWR;
451 450
452 name = mh_expand_name (NULL, folder, 1); 451 name = mh_expand_name (NULL, folder, 1);
453 if (create && mh_check_folder (name, 1)) 452 if ((flags & MU_STREAM_CREAT) && mh_check_folder (name, 1))
454 exit (0); 453 exit (0);
455 454
456 if (mu_mailbox_create_default (&mbox, name)) 455 if (mu_mailbox_create_default (&mbox, name))
...@@ -460,9 +459,6 @@ mh_open_folder (const char *folder, int create) ...@@ -460,9 +459,6 @@ mh_open_folder (const char *folder, int create)
460 exit (1); 459 exit (1);
461 } 460 }
462 461
463 if (create)
464 flags |= MU_STREAM_CREAT;
465
466 if (mu_mailbox_open (mbox, flags)) 462 if (mu_mailbox_open (mbox, flags))
467 { 463 {
468 mu_error (_("cannot open mailbox %s: %s"), name, strerror (errno)); 464 mu_error (_("cannot open mailbox %s: %s"), name, strerror (errno));
...@@ -1045,7 +1041,7 @@ mh_draft_message (const char *name, const char *msgspec, char **pname) ...@@ -1045,7 +1041,7 @@ mh_draft_message (const char *name, const char *msgspec, char **pname)
1045 mu_mailbox_t mbox; 1041 mu_mailbox_t mbox;
1046 const char *path; 1042 const char *path;
1047 1043
1048 mbox = mh_open_folder (name, 0); 1044 mbox = mh_open_folder (name, MU_STREAM_RDWR);
1049 if (!mbox) 1045 if (!mbox)
1050 return 1; 1046 return 1;
1051 1047
......
...@@ -1684,7 +1684,8 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding, ...@@ -1684,7 +1684,8 @@ store_handler (mu_message_t msg, msg_part_t part, char *type, char *encoding,
1684 case store_to_folder_msg: 1684 case store_to_folder_msg:
1685 case store_to_folder: 1685 case store_to_folder:
1686 { 1686 {
1687 mu_mailbox_t mbox = mh_open_folder (name, 1); 1687 mu_mailbox_t mbox = mh_open_folder (name,
1688 MU_STREAM_RDWR|MU_STREAM_CREAT);
1688 size_t uid; 1689 size_t uid;
1689 1690
1690 mu_mailbox_uidnext (mbox, &uid); 1691 mu_mailbox_uidnext (mbox, &uid);
...@@ -2284,12 +2285,12 @@ edit_forw (char *cmd, struct compose_env *env, mu_message_t *pmsg, int level) ...@@ -2284,12 +2285,12 @@ edit_forw (char *cmd, struct compose_env *env, mu_message_t *pmsg, int level)
2284 2285
2285 if (ws.ws_wordv[0][0] == '+') 2286 if (ws.ws_wordv[0][0] == '+')
2286 { 2287 {
2287 mbox = mh_open_folder (ws.ws_wordv[0], 0); 2288 mbox = mh_open_folder (ws.ws_wordv[0], MU_STREAM_RDWR);
2288 i = 1; 2289 i = 1;
2289 } 2290 }
2290 else 2291 else
2291 { 2292 {
2292 mbox = mh_open_folder (mh_current_folder (), 0); 2293 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
2293 i = 0; 2294 i = 0;
2294 } 2295 }
2295 2296
...@@ -2930,7 +2931,7 @@ main (int argc, char **argv) ...@@ -2930,7 +2931,7 @@ main (int argc, char **argv)
2930 } 2931 }
2931 else 2932 else
2932 { 2933 {
2933 mbox = mh_open_folder (mh_current_folder (), 0); 2934 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
2934 mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); 2935 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
2935 } 2936 }
2936 2937
......
...@@ -87,7 +87,7 @@ main (int argc, char **argv) ...@@ -87,7 +87,7 @@ main (int argc, char **argv)
87 exit (0); 87 exit (0);
88 } 88 }
89 89
90 mbox = mh_open_folder (current_folder, 0); 90 mbox = mh_open_folder (current_folder, MU_STREAM_RDWR);
91 91
92 mu_mailbox_messages_count (mbox, &total); 92 mu_mailbox_messages_count (mbox, &total);
93 mu_mailbox_get_url (mbox, &url); 93 mu_mailbox_get_url (mbox, &url);
......
...@@ -80,7 +80,7 @@ main (int argc, char **argv) ...@@ -80,7 +80,7 @@ main (int argc, char **argv)
80 80
81 argc -= index; 81 argc -= index;
82 argv += index; 82 argv += index;
83 mbox = mh_open_folder (mh_current_folder (), 0); 83 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
84 84
85 mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); 85 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
86 if (uid_option) 86 if (uid_option)
......
...@@ -390,7 +390,7 @@ main (int argc, char **argv) ...@@ -390,7 +390,7 @@ main (int argc, char **argv)
390 if (pick_parse (lexlist)) 390 if (pick_parse (lexlist))
391 return 1; 391 return 1;
392 392
393 mbox = mh_open_folder (mh_current_folder (), 0); 393 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
394 394
395 argc -= index; 395 argc -= index;
396 argv += index; 396 argv += index;
......
...@@ -104,7 +104,7 @@ open_folders () ...@@ -104,7 +104,7 @@ open_folders ()
104 mu_mailbox_t mbox; 104 mu_mailbox_t mbox;
105 105
106 mu_iterator_current (itr, (void **)&name); 106 mu_iterator_current (itr, (void **)&name);
107 mbox = mh_open_folder (name, 1); 107 mbox = mh_open_folder (name, MU_STREAM_RDWR|MU_STREAM_CREAT);
108 mu_list_append (folder_mbox_list, mbox); 108 mu_list_append (folder_mbox_list, mbox);
109 free (name); 109 free (name);
110 } 110 }
...@@ -261,7 +261,7 @@ main (int argc, char **argv) ...@@ -261,7 +261,7 @@ main (int argc, char **argv)
261 } 261 }
262 else 262 else
263 { 263 {
264 mbox = mh_open_folder (mh_current_folder (), 0); 264 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
265 mh_msgset_parse (mbox, &msgset, argc, argv, "cur"); 265 mh_msgset_parse (mbox, &msgset, argc, argv, "cur");
266 266
267 status = mh_iterate (mbox, &msgset, refile_iterator, NULL); 267 status = mh_iterate (mbox, &msgset, refile_iterator, NULL);
......
...@@ -407,7 +407,7 @@ main (int argc, char **argv) ...@@ -407,7 +407,7 @@ main (int argc, char **argv)
407 exit (1); 407 exit (1);
408 } 408 }
409 409
410 mbox = mh_open_folder (mh_current_folder (), 0); 410 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
411 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur"); 411 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
412 if (msgset.count != 1) 412 if (msgset.count != 1)
413 { 413 {
......
...@@ -94,7 +94,7 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -94,7 +94,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
94 static char * 94 static char *
95 current_folder_path () 95 current_folder_path ()
96 { 96 {
97 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), 0); 97 mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
98 mu_url_t url; 98 mu_url_t url;
99 char *p; 99 char *p;
100 mu_mailbox_get_url (mbox, &url); 100 mu_mailbox_get_url (mbox, &url);
......
...@@ -73,7 +73,7 @@ main (int argc, char **argv) ...@@ -73,7 +73,7 @@ main (int argc, char **argv)
73 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc, 73 mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
74 opt_handler, NULL, &index); 74 opt_handler, NULL, &index);
75 75
76 mbox = mh_open_folder (mh_current_folder (), 0); 76 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
77 77
78 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur"); 78 mh_msgset_parse (mbox, &msgset, argc - index, argv + index, "cur");
79 79
......
...@@ -179,7 +179,7 @@ main (int argc, char **argv) ...@@ -179,7 +179,7 @@ main (int argc, char **argv)
179 exit (1); 179 exit (1);
180 } 180 }
181 181
182 mbox = mh_open_folder (mh_current_folder (), 0); 182 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
183 183
184 argc -= index; 184 argc -= index;
185 argv += index; 185 argv += index;
......
...@@ -765,7 +765,7 @@ main (int argc, char **argv) ...@@ -765,7 +765,7 @@ main (int argc, char **argv)
765 const char *path; 765 const char *path;
766 size_t i; 766 size_t i;
767 767
768 mbox = mh_open_folder (draftfolder, 1); 768 mbox = mh_open_folder (draftfolder, MU_STREAM_RDWR|MU_STREAM_CREAT);
769 mh_msgset_parse (mbox, &msgset, argc, argv, draftmessage); 769 mh_msgset_parse (mbox, &msgset, argc, argv, draftmessage);
770 mu_mailbox_get_url (mbox, &url); 770 mu_mailbox_get_url (mbox, &url);
771 mu_url_sget_path (url, &path); 771 mu_url_sget_path (url, &path);
......
...@@ -93,6 +93,7 @@ static int verbose; ...@@ -93,6 +93,7 @@ static int verbose;
93 static mu_mailbox_t mbox; 93 static mu_mailbox_t mbox;
94 static const char *mbox_path; 94 static const char *mbox_path;
95 static mh_msgset_t msgset; 95 static mh_msgset_t msgset;
96 static size_t current_num;
96 97
97 #define ACTION_REORDER 0 98 #define ACTION_REORDER 0
98 #define ACTION_DRY_RUN 1 99 #define ACTION_DRY_RUN 1
...@@ -193,7 +194,8 @@ opt_handler (int key, char *arg, struct argp_state *state) ...@@ -193,7 +194,8 @@ opt_handler (int key, char *arg, struct argp_state *state)
193 194
194 195
195 /* *********************** Comparison functions **************************** */ 196 /* *********************** Comparison functions **************************** */
196 struct comp_op { 197 struct comp_op
198 {
197 char *field; 199 char *field;
198 compfun comp; 200 compfun comp;
199 }; 201 };
...@@ -219,7 +221,8 @@ addop (char *field, compfun comp) ...@@ -219,7 +221,8 @@ addop (char *field, compfun comp)
219 mu_list_append (oplist, op); 221 mu_list_append (oplist, op);
220 } 222 }
221 223
222 struct rem_data { 224 struct rem_data
225 {
223 struct comp_op *op; 226 struct comp_op *op;
224 compfun comp; 227 compfun comp;
225 }; 228 };
...@@ -244,7 +247,8 @@ remop (compfun comp) ...@@ -244,7 +247,8 @@ remop (compfun comp)
244 mu_list_remove (oplist, d.op); 247 mu_list_remove (oplist, d.op);
245 } 248 }
246 249
247 struct comp_data { 250 struct comp_data
251 {
248 int r; 252 int r;
249 mu_message_t m[2]; 253 mu_message_t m[2];
250 }; 254 };
...@@ -491,7 +495,7 @@ sort () ...@@ -491,7 +495,7 @@ sort ()
491 switch (algorithm) 495 switch (algorithm)
492 { 496 {
493 case ARG_QUICKSORT: 497 case ARG_QUICKSORT:
494 qsort(msgset.list, msgset.count, sizeof(msgset.list[0]), 498 qsort(msgset.list, msgset.count, sizeof (msgset.list[0]),
495 comp); 499 comp);
496 break; 500 break;
497 501
...@@ -528,14 +532,36 @@ sort () ...@@ -528,14 +532,36 @@ sort ()
528 mh_message_number (msg, &new_num); 532 mh_message_number (msg, &new_num);
529 transpose (i, oldlist[i]); 533 transpose (i, oldlist[i]);
530 if (verbose) 534 if (verbose)
531 fprintf (stderr, "{%s, %s}\n", 535 {
536 fprintf (stderr, "{%s, %s}",
532 mu_umaxtostr (0, old_num), 537 mu_umaxtostr (0, old_num),
533 mu_umaxtostr (1, new_num)); 538 mu_umaxtostr (1, new_num));
539 }
540 if (old_num == current_num)
541 {
542 if (verbose)
543 fputc ('*', stderr);
544 current_num = new_num;
545 }
546 else if (new_num == current_num)
547 {
548 if (verbose)
549 fputc ('*', stderr);
550 current_num = old_num;
551 }
552 if (verbose)
553 fputc ('\n', stderr);
534 if (action == ACTION_REORDER) 554 if (action == ACTION_REORDER)
535 swap_message (old_num, new_num); 555 swap_message (old_num, new_num);
536 } 556 }
537 } 557 }
538 } 558 }
559 if (action == ACTION_REORDER)
560 {
561 mu_mailbox_close (mbox);
562 mu_mailbox_open (mbox, MU_STREAM_RDWR);
563 mh_mailbox_set_cur (mbox, current_num);
564 }
539 } 565 }
540 566
541 567
...@@ -560,7 +586,7 @@ main (int argc, char **argv) ...@@ -560,7 +586,7 @@ main (int argc, char **argv)
560 exit (1); 586 exit (1);
561 } 587 }
562 588
563 mbox = mh_open_folder (mh_current_folder (), 0); 589 mbox = mh_open_folder (mh_current_folder (), MU_STREAM_READ);
564 mu_mailbox_get_url (mbox, &url); 590 mu_mailbox_get_url (mbox, &url);
565 mbox_path = mu_url_to_string (url); 591 mbox_path = mu_url_to_string (url);
566 if (memcmp (mbox_path, "mh:", 3) == 0) 592 if (memcmp (mbox_path, "mh:", 3) == 0)
...@@ -569,7 +595,12 @@ main (int argc, char **argv) ...@@ -569,7 +595,12 @@ main (int argc, char **argv)
569 argc -= index; 595 argc -= index;
570 argv += index; 596 argv += index;
571 597
598 mh_mailbox_get_cur (mbox, &current_num);
599
572 mh_msgset_parse (mbox, &msgset, argc, argv, "all"); 600 mh_msgset_parse (mbox, &msgset, argc, argv, "all");
573 sort (mbox, msgset); 601 sort ();
602 mh_global_save_state ();
603 mu_mailbox_destroy (&mbox);
604
574 return 0; 605 return 0;
575 } 606 }
......
...@@ -56,6 +56,7 @@ TESTSUITE_AT = \ ...@@ -56,6 +56,7 @@ TESTSUITE_AT = \
56 pick.at\ 56 pick.at\
57 scan.at\ 57 scan.at\
58 send.at\ 58 send.at\
59 sortm.at\
59 refile.at\ 60 refile.at\
60 repl.at\ 61 repl.at\
61 rmf.at\ 62 rmf.at\
......
...@@ -81,3 +81,4 @@ m4_include([forw.at]) ...@@ -81,3 +81,4 @@ m4_include([forw.at])
81 m4_include([repl.at]) 81 m4_include([repl.at])
82 m4_include([mhn.at]) 82 m4_include([mhn.at])
83 m4_include([send.at]) 83 m4_include([send.at])
84 m4_include([sortm.at])
......
...@@ -42,7 +42,7 @@ mh_whatnow_env_from_environ (struct mh_whatnow_env *wh) ...@@ -42,7 +42,7 @@ mh_whatnow_env_from_environ (struct mh_whatnow_env *wh)
42 size_t i; 42 size_t i;
43 struct mu_wordsplit ws; 43 struct mu_wordsplit ws;
44 mh_msgset_t msgset; 44 mh_msgset_t msgset;
45 mu_mailbox_t mbox = mh_open_folder (folder, 0); 45 mu_mailbox_t mbox = mh_open_folder (folder, MU_STREAM_RDWR);
46 46
47 if (mu_wordsplit (p, &ws, 47 if (mu_wordsplit (p, &ws,
48 MU_WRDSF_DEFFLAGS & ~MU_WRDSF_CESCAPES)) 48 MU_WRDSF_DEFFLAGS & ~MU_WRDSF_CESCAPES))
......