ZOOM C: don't trust recordPosition always
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 Oct 2012 09:42:28 +0000 (11:42 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 Oct 2012 09:42:28 +0000 (11:42 +0200)
Some servers, such as IGI global's SRU service uses a recordPosition
scheme starting from zero. First record's position should be one
according to the standard.

src/zoom-sru.c

index 87de7c3..687ca83 100644 (file)
@@ -313,7 +313,7 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
         }
         for (i = 0; i<res->num_records; i++)
         {
-            int pos;
+            int pos = *start + i;
             Z_SRW_record *sru_rec;
             Z_SRW_diagnostic *diag = 0;
             int num_diag;
@@ -321,12 +321,10 @@ static zoom_ret handle_srw_response(ZOOM_connection c,
             Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
                 odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
 
-            /* recordPosition is 1 based */
+            /* only trust recordPosition if >= calculated position */
             if (res->records[i].recordPosition &&
-                *res->records[i].recordPosition > 0)
+                *res->records[i].recordPosition >= pos + 1)
                 pos = *res->records[i].recordPosition - 1;
-            else
-                pos = *start + i;
 
             sru_rec = &res->records[i];