projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sorted authors
[idzebra-moved-to-github.git]
/
index
/
extract.c
diff --git
a/index/extract.c
b/index/extract.c
index
45fde5d
..
3a6f8c2
100644
(file)
--- a/
index/extract.c
+++ b/
index/extract.c
@@
-1,4
+1,4
@@
-/* $Id: extract.c,v 1.199 2005-11-10 11:25:47 adam Exp $
+/* $Id: extract.c,v 1.202 2006-02-09 08:31:02 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
Copyright (C) 1995-2005
Index Data ApS
@@
-32,6
+32,7
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <fcntl.h>
#include "index.h"
#include <fcntl.h>
#include "index.h"
+#include "orddict.h"
#include <direntz.h>
#include <charmap.h>
#include <direntz.h>
#include <charmap.h>
@@
-206,6
+207,8
@@
static void file_end (void *handle, off_t offset)
}
}
}
}
+#define FILE_MATCH_BLANK "\t "
+
static char *fileMatchStr (ZebraHandle zh,
zebra_rec_keys_t reckeys,
const char *fname, const char *spec)
static char *fileMatchStr (ZebraHandle zh,
zebra_rec_keys_t reckeys,
const char *fname, const char *spec)
@@
-216,8
+219,8
@@
static char *fileMatchStr (ZebraHandle zh,
while (1)
{
while (1)
{
- while (*s == ' ' || *s == '\t')
- s++;
+ for (; *s && strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (!*s)
break;
if (*s == '(')
if (!*s)
break;
if (*s == '(')
@@
-226,21
+229,26
@@
static char *fileMatchStr (ZebraHandle zh,
char attset_str[64], attname_str[64];
data1_attset *attset;
int i;
char attset_str[64], attname_str[64];
data1_attset *attset;
int i;
- char matchFlag[32];
int attSet = 1, attUse = 1;
int first = 1;
int attSet = 1, attUse = 1;
int first = 1;
-
- s++;
- for (i = 0; *s && *s != ',' && *s != ')'; s++)
- if (i < 63)
+
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ',' && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attset_str))
attset_str[i++] = *s;
attset_str[i] = '\0';
attset_str[i++] = *s;
attset_str[i] = '\0';
-
+
+ for (; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
if (*s == ',')
{
if (*s == ',')
{
- s++;
- for (i = 0; *s && *s != ')'; s++)
- if (i < 63)
+ for (s++; strchr(FILE_MATCH_BLANK, *s); s++)
+ ;
+ for (i = 0; *s && *s != ')' &&
+ !strchr(FILE_MATCH_BLANK, *s); s++)
+ if (i+1 < sizeof(attname_str))
attname_str[i++] = *s;
attname_str[i] = '\0';
}
attname_str[i++] = *s;
attname_str[i] = '\0';
}
@@
-257,12
+265,7
@@
static char *fileMatchStr (ZebraHandle zh,
}
searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
}
searchRecordKey (zh, reckeys, attSet, attUse, ws, 32);
- if (*s == ')')
- {
- for (i = 0; i<32; i++)
- matchFlag[i] = 1;
- }
- else
+ if (*s != ')')
{
yaz_log (YLOG_WARN, "Missing ) in match criteria %s in group %s",
spec, zh->m_group ? zh->m_group : "none");
{
yaz_log (YLOG_WARN, "Missing ) in match criteria %s in group %s",
spec, zh->m_group ? zh->m_group : "none");
@@
-271,7
+274,7
@@
static char *fileMatchStr (ZebraHandle zh,
s++;
for (i = 0; i<32; i++)
s++;
for (i = 0; i<32; i++)
- if (matchFlag[i] && ws[i])
+ if (ws[i])
{
if (first)
{
{
if (first)
{
@@
-294,12
+297,12
@@
static char *fileMatchStr (ZebraHandle zh,
char special[64];
const char *spec_src = NULL;
const char *s1 = ++s;
char special[64];
const char *spec_src = NULL;
const char *s1 = ++s;
- while (*s1 && *s1 != ' ' && *s1 != '\t')
+ while (*s1 && !strchr(FILE_MATCH_BLANK, *s1))
s1++;
spec_len = s1 - s;
s1++;
spec_len = s1 - s;
- if (spec_len > 63)
- spec_len = 63;
+ if (spec_len > sizeof(special)-1)
+ spec_len = sizeof(special)-1;
memcpy (special, s, spec_len);
special[spec_len] = '\0';
s = s1;
memcpy (special, s, spec_len);
special[spec_len] = '\0';
s = s1;
@@
-329,7
+332,7
@@
static char *fileMatchStr (ZebraHandle zh,
while (*s && *s != stopMarker)
{
while (*s && *s != stopMarker)
{
- if (i < 63)
+ if (i+1 < sizeof(tmpString))
tmpString[i++] = *s++;
}
if (*s)
tmpString[i++] = *s++;
}
if (*s)
@@
-490,7
+493,9
@@
static int file_extract_record(ZebraHandle zh,
}
if (matchStr)
{
}
if (matchStr)
{
- char *rinfo = dict_lookup (zh->reg->matchDict, matchStr);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord,
+ matchStr);
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
@@
-533,7
+538,9
@@
static int file_extract_record(ZebraHandle zh,
if (matchStr)
{
if (matchStr)
{
- dict_insert (zh->reg->matchDict, matchStr, sizeof(*sysno), sysno);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_insert_ord(zh->reg->matchDict, db_ord, matchStr,
+ sizeof(*sysno), sysno);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
@@
-595,7
+602,10
@@
static int file_extract_record(ZebraHandle zh,
zh->m_record_type, fname, recordOffset);
zh->records_deleted++;
if (matchStr)
zh->m_record_type, fname, recordOffset);
zh->records_deleted++;
if (matchStr)
- dict_delete (zh->reg->matchDict, matchStr);
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_ord(zh->reg->matchDict, db_ord, matchStr);
+ }
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);
@@
-845,6
+855,7
@@
ZEBRA_RES buffer_extract_record(ZebraHandle zh,
int force_update,
int allow_update)
{
int force_update,
int allow_update)
{
+ SYSNO sysno0 = 0;
RecordAttr *recordAttr;
struct recExtractCtrl extractCtrl;
int r;
RecordAttr *recordAttr;
struct recExtractCtrl extractCtrl;
int r;
@@
-942,14
+953,14
@@
ZEBRA_RES buffer_extract_record(ZebraHandle zh,
yaz_log (YLOG_WARN, "extract error: no such filter");
return ZEBRA_FAIL;
}
yaz_log (YLOG_WARN, "extract error: no such filter");
return ZEBRA_FAIL;
}
- /* match criteria */
- matchStr = NULL;
if (extractCtrl.match_criteria[0])
match_criteria = extractCtrl.match_criteria;
if (extractCtrl.match_criteria[0])
match_criteria = extractCtrl.match_criteria;
- if (! *sysno) {
- char *rinfo;
+ if (!sysno) {
+
+ sysno = &sysno0;
+
if (match_criteria && *match_criteria) {
matchStr = match_criteria;
} else {
if (match_criteria && *match_criteria) {
matchStr = match_criteria;
} else {
@@
-963,8
+974,11
@@
ZEBRA_RES buffer_extract_record(ZebraHandle zh,
}
}
}
}
}
}
- if (matchStr) {
- rinfo = dict_lookup (zh->reg->matchDict, matchStr);
+ if (matchStr)
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ char *rinfo = dict_lookup_ord(zh->reg->matchDict, db_ord,
+ matchStr);
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
if (rinfo)
{
assert(*rinfo == sizeof(*sysno));
@@
-1002,8
+1016,9
@@
ZEBRA_RES buffer_extract_record(ZebraHandle zh,
if (matchStr)
{
if (matchStr)
{
- dict_insert (zh->reg->matchDict, matchStr,
- sizeof(*sysno), sysno);
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_insert_ord(zh->reg->matchDict, db_ord, matchStr,
+ sizeof(*sysno), sysno);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
}
#if NATTR
extract_flushSortKeys (zh, *sysno, 1, zh->reg->sortKeys);
@@
-1079,7
+1094,10
@@
ZEBRA_RES buffer_extract_record(ZebraHandle zh,
pr_fname, (long) recordOffset);
zh->records_deleted++;
if (matchStr)
pr_fname, (long) recordOffset);
zh->records_deleted++;
if (matchStr)
- dict_delete (zh->reg->matchDict, matchStr);
+ {
+ int db_ord = zebraExplain_get_database_ord(zh->reg->zei);
+ dict_delete_ord(zh->reg->matchDict, db_ord, matchStr);
+ }
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);
rec_del (zh->reg->records, &rec);
}
rec_rm (&rec);