Commit b99ca824 b99ca824f0afdf2f47c8771dfaa244b11fd43691 by Sergey Poznyakoff

(burst): Keep message sequence number in msgno.

(burst_rename): Fix loop limits
(main): Fix calculation of last_uid.
Keep message sequence numbers in ms.
1 parent 4a5df14a
...@@ -222,7 +222,7 @@ void ...@@ -222,7 +222,7 @@ void
222 burst (mu_mailbox_t mbox, mu_message_t msg, size_t num, void *data) 222 burst (mu_mailbox_t mbox, mu_message_t msg, size_t num, void *data)
223 { 223 {
224 memset (&map, 0, sizeof (map)); 224 memset (&map, 0, sizeof (map));
225 map.msgno = num; 225 mh_message_number (msg, &map.msgno);
226 226
227 if (burst_or_copy (msg, 1, 0) == 0) 227 if (burst_or_copy (msg, 1, 0) == 0)
228 { 228 {
...@@ -251,14 +251,14 @@ burst_rename (mh_msgset_t *ms, size_t lastuid) ...@@ -251,14 +251,14 @@ burst_rename (mh_msgset_t *ms, size_t lastuid)
251 char *from; 251 char *from;
252 char *to; 252 char *to;
253 253
254 if (ms->list[i] == burst_map[j].msgno) 254 if (ms->list[i-1] == burst_map[j].msgno)
255 { 255 {
256 lastuid -= burst_map[j].count; 256 lastuid -= burst_map[j].count;
257 burst_map[j].msgno = lastuid; 257 burst_map[j].msgno = lastuid;
258 j--; 258 j--;
259 } 259 }
260 260
261 asprintf (&from, "%lu", (unsigned long) ms->list[i]); 261 asprintf (&from, "%lu", (unsigned long) ms->list[i-1]);
262 asprintf (&to, "%lu", (unsigned long) lastuid); 262 asprintf (&to, "%lu", (unsigned long) lastuid);
263 --lastuid; 263 --lastuid;
264 264
...@@ -391,7 +391,7 @@ main (int argc, char **argv) ...@@ -391,7 +391,7 @@ main (int argc, char **argv)
391 burst_map = obstack_finish (&stk); 391 burst_map = obstack_finish (&stk);
392 392
393 mu_mailbox_uidnext (mbox, &next_uid); 393 mu_mailbox_uidnext (mbox, &next_uid);
394 for (i = 0, last_uid = next_uid; i < burst_count; i++) 394 for (i = 0, last_uid = next_uid-1; i < burst_count; i++)
395 last_uid += burst_map[i].count; 395 last_uid += burst_map[i].count;
396 VERBOSE ((_("Estimated last UID: %lu"), (unsigned long) last_uid)); 396 VERBOSE ((_("Estimated last UID: %lu"), (unsigned long) last_uid));
397 397
...@@ -400,6 +400,7 @@ main (int argc, char **argv) ...@@ -400,6 +400,7 @@ main (int argc, char **argv)
400 xargv[1] = NULL; 400 xargv[1] = NULL;
401 mh_msgset_parse (mbox, &ms, 1, xargv, NULL); 401 mh_msgset_parse (mbox, &ms, 1, xargv, NULL);
402 free (xargv[0]); 402 free (xargv[0]);
403 mh_msgset_uids (mbox, &ms);
403 404
404 mu_mailbox_get_url (mbox, &dst_url); 405 mu_mailbox_get_url (mbox, &dst_url);
405 dir = mu_url_to_string (dst_url); 406 dir = mu_url_to_string (dst_url);
......