mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
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:
parent
363fc8c5e2
commit
4633d18db3
22
src/elogd.c
22
src/elogd.c
@ -8620,14 +8620,22 @@ auto-increment tags */
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
el_retrieve(lbs, message_id, NULL, attr_list, attrib, lbs->n_attr, NULL, 0, NULL, NULL, att, NULL, NULL);
|
/* 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);
|
||||||
|
|
||||||
/* 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 */
|
||||||
old_index = atoi(attrib[index] + loc);
|
if (atoi(attrib[index] + loc) > old_index)
|
||||||
|
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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user