- int j, j0 = -1;
- const char *mterm = NULL;
- const char *tst;
- RSET rset;
- int lo = before-1-i; /* offset in result list */
- zint count;
-
- for (j = 0; j <ord_no; j++)
- {
- if (ptr[j] < before && ptr[j] >= 0 &&
- (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
- (!mterm || strcmp (tst, mterm) > 0))
- {
- j0 = j;
- mterm = tst;
- }
- }
- if (j0 == -1)
- break;
-
- zebra_term_untrans_iconv(zh, stream->mem, index_type,
- &glist[lo].term, mterm);
-
- rset = rset_trunc
- (zh, &scan_info_array[j0].list[before-1-ptr[j0]].isam_p, 1,
- glist[lo].term, strlen(glist[lo].term),
- NULL, 0, zapt->term->which, rset_nmem,
- kc, kc->scope, 0, index_type, 0 /* hits_limit */,
- 0 /* term_ref_id_str */);
-
- ptr[j0]++;
-
- for (j = j0+1; j<ord_no; j++)
- {
- if (ptr[j] < before && ptr[j] >= 0 &&
- (tst = scan_info_array[j].list[before-1-ptr[j]].term) &&
- !strcmp (tst, mterm))
- {
- RSET rsets[2];
-
- rsets[0] = rset;
- rsets[1] = rset_trunc(
- zh,
- &scan_info_array[j].list[before-1-ptr[j]].isam_p, 1,
- glist[lo].term,
- strlen(glist[lo].term), NULL, 0,
- zapt->term->which, rset_nmem,
- kc, kc->scope, 0, index_type, 0 /* hits_limit */,
- 0 /* term_ref_id_str */);
- rset = rset_create_or(rset_nmem, kc,
- kc->scope, 0 /* termid */, 2, rsets);
-
- ptr[j]++;
- }
- }
- if (limit_set)
- {
- RSET rsets[2];
- rsets[0] = rset;
- rsets[1] = rset_dup(limit_set);
-
- rset = rset_create_and(rset_nmem, kc, kc->scope, 2, rsets);
- }
- count_set(zh, rset, &count);
- glist[lo].occurrences = count;
- rset_delete (rset);
+ char termz[IT_MAX_WORD+20];
+ int prefix_len = 0;
+
+ prefix_len = key_SU_encode(ords[i], termz);
+ termz[prefix_len] = 0;
+ strcpy(ar[i].prefix, termz);
+
+ if (trans_scan_term(zh, zapt, termz+prefix_len, zm) ==
+ ZEBRA_FAIL)
+ return ZEBRA_FAIL;
+ wrbuf_rewind(ar[i].term);
+ wrbuf_puts(ar[i].term, termz + prefix_len);
+ ar[i].isam_p = 0;
+ ar[i].ord = ords[i];