From: Adam Dickmeiss Date: Tue, 13 Sep 2011 20:32:08 +0000 (+0200) Subject: Preserve order for merged metadata X-Git-Tag: v1.6.1~9 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=598a773ffcb4f45f5ca74b1f8f217c8fc9cf3bc0;p=pazpar2-moved-to-github.git Preserve order for merged metadata Fixes issue mentioned by Sven Porst http://lists.indexdata.dk/pipermail/yazlist/2011-July/003230.html --- diff --git a/src/session.c b/src/session.c index fa9ebb3..d56b396 100644 --- a/src/session.c +++ b/src/session.c @@ -1453,16 +1453,15 @@ static int ingest_to_cluster(struct client *cl, // assign cluster or record based on merge action if (ser_md->merge == Metadata_merge_unique) { - struct record_metadata *mnode; - for (mnode = *wheretoput; mnode; mnode = mnode->next) - if (!strcmp((const char *) mnode->data.text.disp, + while (*wheretoput) + { + if (!strcmp((const char *) (*wheretoput)->data.text.disp, rec_md->data.text.disp)) break; - if (!mnode) - { - rec_md->next = *wheretoput; - *wheretoput = rec_md; + wheretoput = &(*wheretoput)->next; } + if (!*wheretoput) + *wheretoput = rec_md; } else if (ser_md->merge == Metadata_merge_longest) { @@ -1507,7 +1506,8 @@ static int ingest_to_cluster(struct client *cl, } else if (ser_md->merge == Metadata_merge_all) { - rec_md->next = *wheretoput; + while (*wheretoput) + wheretoput = &(*wheretoput)->next; *wheretoput = rec_md; } else if (ser_md->merge == Metadata_merge_range) diff --git a/test/test_http_23.res b/test/test_http_23.res index c248dbb..a3476cd 100644 --- a/test/test_http_23.res +++ b/test/test_http_23.res @@ -6,8 +6,8 @@ How to program a computer Jack Collins -11224467 -11224466 +11224466 +11224467 How to program a computer Jack Collins 11224467 diff --git a/test/test_http_6.res b/test/test_http_6.res index c0c00f3..f079915 100644 --- a/test/test_http_6.res +++ b/test/test_http_6.res @@ -6,8 +6,8 @@ How to program a computer Jack Collins -11224467 -11224466 +11224466 +11224467 How to program a computer Jack Collins 11224467