Calculate index for automatically incremented preset attributes by searching all old messages for the highest used index

SVN revision: 2073
This commit is contained in:
Stefan Ritt 2008-03-07 19:38:43 +00:00
parent 363fc8c5e2
commit 4633d18db3

View File

@ -8620,15 +8620,23 @@ auto-increment tags */
return; return;
} }
/* search all entries to find largest index */
old_index = 0;
do {
el_retrieve(lbs, message_id, NULL, attr_list, attrib, lbs->n_attr, NULL, 0, NULL, NULL, att, NULL, NULL); el_retrieve(lbs, message_id, NULL, attr_list, attrib, lbs->n_attr, NULL, 0, NULL, NULL, att, NULL, NULL);
/* if date part changed, start over with inded */ /* if date part changed, start over with index */
if (strncmp(attrib[index], retstr, loc) != 0) if (strncmp(attrib[index], retstr, loc) != 0)
old_index = 0; old_index = 0;
else else
/* retrieve old index */ /* retrieve old index */
if (atoi(attrib[index] + loc) > old_index)
old_index = atoi(attrib[index] + loc); old_index = atoi(attrib[index] + loc);
message_id = el_search_message(lbs, EL_PREV, message_id, FALSE);
} while (message_id);
/* increment index */ /* increment index */
sprintf(retstr + loc, "%0*d", len, old_index + 1); sprintf(retstr + loc, "%0*d", len, old_index + 1);
} }