@@ -426,7 +426,7 @@ EXPORTED int index_expunge(struct index_state *state, const char *sequence,
426
426
continue ; /* no \Deleted flag */
427
427
428
428
/* if there is a sequence list, check it */
429
- if (sequence && !seqset_ismember (seq , im -> uid ))
429
+ if (seq && !seqset_ismember (seq , im -> uid ))
430
430
continue ; /* not in the list */
431
431
432
432
/* load first once we know we have to process this one */
@@ -469,7 +469,7 @@ EXPORTED int index_expunge(struct index_state *state, const char *sequence,
469
469
mboxevent_extract_record (mboxevent , state -> mailbox , & record );
470
470
}
471
471
472
- seqset_free (& seq );
472
+ if ( seq != state -> searchres ) seqset_free (& seq );
473
473
474
474
mboxevent_extract_mailbox (mboxevent , state -> mailbox );
475
475
mboxevent_set_access (mboxevent , NULL , NULL , state -> userid , mailbox_name (state -> mailbox ), 1 );
@@ -877,16 +877,16 @@ EXPORTED void index_select(struct index_state *state, struct index_init *init)
877
877
}
878
878
879
879
sequence = init -> vanished .sequence ;
880
- if ( sequence ) seq = _parse_sequence (state , sequence , 1 );
880
+ seq = _parse_sequence (state , sequence , 1 );
881
881
for (msgno = 1 ; msgno <= state -> exists ; msgno ++ ) {
882
882
im = & state -> map [msgno - 1 ];
883
- if (sequence && !seqset_ismember (seq , im -> uid ))
883
+ if (seq && !seqset_ismember (seq , im -> uid ))
884
884
continue ;
885
885
if (im -> modseq <= init -> vanished .modseq )
886
886
continue ;
887
887
index_printflags (state , msgno , TELL_UID );
888
888
}
889
- seqset_free (& seq );
889
+ if ( seq != state -> searchres ) seqset_free (& seq );
890
890
}
891
891
}
892
892
@@ -972,7 +972,7 @@ seqset_t *index_vanished(struct index_state *state,
972
972
const struct index_record * record = msg_record (msg );
973
973
if (!(record -> internal_flags & FLAG_INTERNAL_EXPUNGED ))
974
974
continue ;
975
- if (!params -> sequence || seqset_ismember (seq , record -> uid ))
975
+ if (!seq || seqset_ismember (seq , record -> uid ))
976
976
seqset_add (outlist , record -> uid , 1 );
977
977
}
978
978
mailbox_iter_done (& iter );
@@ -1036,7 +1036,7 @@ seqset_t *index_vanished(struct index_state *state,
1036
1036
}
1037
1037
}
1038
1038
1039
- seqset_free (& seq );
1039
+ if ( seq != state -> searchres ) seqset_free (& seq );
1040
1040
1041
1041
return outlist ;
1042
1042
}
@@ -1211,11 +1211,11 @@ EXPORTED int index_fetch(struct index_state *state,
1211
1211
r = index_lock (state , readonly );
1212
1212
if (r ) return r ;
1213
1213
1214
- if (! strcmp ( "$" , sequence )) {
1215
- seq = state -> searchres ;
1214
+ seq = _parse_sequence ( state , sequence , usinguid );
1215
+ if (! strcmpsafe ( "$" , sequence )) {
1216
1216
usinguid = 1 ;
1217
1217
1218
- if (!seqset_first (state -> searchres )) {
1218
+ if (!seqset_first (seq )) {
1219
1219
/* RFC 5182: 2.1
1220
1220
* Note that even if the "$" marker contains the empty list of
1221
1221
* messages, it must be treated by all commands accepting message
@@ -1227,9 +1227,6 @@ EXPORTED int index_fetch(struct index_state *state,
1227
1227
goto done ;
1228
1228
}
1229
1229
}
1230
- else {
1231
- seq = _parse_sequence (state , sequence , usinguid );
1232
- }
1233
1230
1234
1231
/* set the \Seen flag if necessary - while we still have the lock */
1235
1232
if (!readonly ) {
@@ -1365,11 +1362,11 @@ EXPORTED int index_store(struct index_state *state, const char *sequence,
1365
1362
1366
1363
mailbox = state -> mailbox ;
1367
1364
1365
+ seq = _parse_sequence (state , sequence , storeargs -> usinguid );
1368
1366
if (!strcmp ("$" , sequence )) {
1369
- seq = state -> searchres ;
1370
1367
storeargs -> usinguid = 1 ;
1371
1368
1372
- if (!seqset_first (state -> searchres )) {
1369
+ if (!seqset_first (seq )) {
1373
1370
/* RFC 5182: 2.1
1374
1371
* Note that even if the "$" marker contains the empty list of
1375
1372
* messages, it must be treated by all commands accepting message
@@ -1378,9 +1375,6 @@ EXPORTED int index_store(struct index_state *state, const char *sequence,
1378
1375
goto done ;
1379
1376
}
1380
1377
}
1381
- else {
1382
- seq = _parse_sequence (state , sequence , storeargs -> usinguid );
1383
- }
1384
1378
1385
1379
for (i = 0 ; i < flags -> count ; i ++ ) {
1386
1380
r = mailbox_user_flag (mailbox , flags -> data [i ], & userflag , 1 );
@@ -1615,7 +1609,7 @@ EXPORTED int index_run_annotator(struct index_state *state,
1615
1609
}
1616
1610
1617
1611
out :
1618
- seqset_free (& seq );
1612
+ if ( seq != state -> searchres ) seqset_free (& seq );
1619
1613
1620
1614
if (msgrec ) msgrecord_unref (& msgrec );
1621
1615
if (!r ) {
@@ -3147,7 +3141,9 @@ EXPORTED int index_copy(struct index_state *state,
3147
3141
3148
3142
srcmailbox = state -> mailbox ;
3149
3143
3150
- if (!strcmp ("$" , sequence )) {
3144
+ seq = _parse_sequence (state , sequence , usinguid );
3145
+ if (!strcmpsafe ("$" , sequence )) {
3146
+ usinguid = 1 ;
3151
3147
if (!seqset_first (state -> searchres )) {
3152
3148
/* RFC 5182: 2.1
3153
3149
* Note that even if the "$" marker contains the empty list of
@@ -3156,12 +3152,6 @@ EXPORTED int index_copy(struct index_state *state,
3156
3152
*/
3157
3153
return 0 ;
3158
3154
}
3159
-
3160
- seq = state -> searchres ;
3161
- usinguid = 1 ;
3162
- }
3163
- else {
3164
- seq = _parse_sequence (state , sequence , usinguid );
3165
3155
}
3166
3156
3167
3157
for (msgno = 1 ; msgno <= state -> exists ; msgno ++ ) {
@@ -3369,7 +3359,7 @@ EXPORTED int index_copy_remote(struct index_state *state, const char *sequence,
3369
3359
index_appendremote (state , msgno , pout );
3370
3360
}
3371
3361
3372
- seqset_free (& seq );
3362
+ if ( seq != state -> searchres ) seqset_free (& seq );
3373
3363
3374
3364
return 0 ;
3375
3365
}
@@ -8249,6 +8239,13 @@ static seqset_t *_parse_sequence(struct index_state *state,
8249
8239
{
8250
8240
unsigned maxval ;
8251
8241
8242
+ // handle no sequence
8243
+ if (!sequence ) return NULL ;
8244
+
8245
+ // handle saved sequences
8246
+ if (!strcmpsafe ("$" , sequence ))
8247
+ return state -> searchres ;
8248
+
8252
8249
/* Per RFC 3501, seq-number ABNF:
8253
8250
"*" represents the largest number in use.
8254
8251
In the case of message sequence numbers,
0 commit comments