- e->which = Z_Entry_termInfo;
- e->u.termInfo = t = (Z_TermInfo *)odr_malloc(assoc->encode, sizeof(*t));
- t->suggestedAttributes = 0;
- t->displayTerm = 0;
- t->alternativeTerm = 0;
- t->byAttributes = 0;
- t->otherTermInfo = 0;
- t->globalOccurrences = &srs->entries[i].occurrences;
- t->term = (Z_Term *)odr_malloc(assoc->encode, sizeof(*t->term));
- t->term->which = Z_Term_general;
- t->term->u.general = o = (Odr_oct *)odr_malloc(assoc->encode,
- sizeof(Odr_oct));
- o->buf = (unsigned char *)odr_malloc(assoc->encode, o->len = o->size =
- strlen(srs->entries[i].term));
- memcpy(o->buf, srs->entries[i].term, o->len);
- logf(LOG_DEBUG, " term #%d: '%s' (%d)", i,
- srs->entries[i].term, srs->entries[i].occurrences);
+ if (srs->entries[i].occurrences >= 0)
+ {
+ e->which = Z_Entry_termInfo;
+ e->u.termInfo = t = (Z_TermInfo *)
+ odr_malloc(assoc->encode, sizeof(*t));
+ t->suggestedAttributes = 0;
+ t->displayTerm = 0;
+ t->alternativeTerm = 0;
+ t->byAttributes = 0;
+ t->otherTermInfo = 0;
+ t->globalOccurrences = &srs->entries[i].occurrences;
+ t->term = (Z_Term *)
+ odr_malloc(assoc->encode, sizeof(*t->term));
+ t->term->which = Z_Term_general;
+ t->term->u.general = o =
+ (Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct));
+ o->buf = (unsigned char *)
+ odr_malloc(assoc->encode, o->len = o->size =
+ strlen(srs->entries[i].term));
+ memcpy(o->buf, srs->entries[i].term, o->len);
+ logf(LOG_DEBUG, " term #%d: '%s' (%d)", i,
+ srs->entries[i].term, srs->entries[i].occurrences);
+ }
+ else
+ {
+ Z_Records *zrecords = diagrec (assoc,
+ srs->entries[i].errcode,
+ srs->entries[i].errstring);
+ logf(LOG_DEBUG, " term sd code=%d addinfo=%s",
+ srs->entries[i].errcode,
+ (srs->entries[i].errstring?srs->entries[i].errstring :
+ "<null>"));
+ assert (zrecords->which == Z_Records_NSD);
+ e->which = Z_Entry_surrogateDiagnostic;
+ e->u.surrogateDiagnostic =
+ zrecords->u.nonSurrogateDiagnostic;
+ }