X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fextract.c;h=593c9e8deda4c7ffe7e68bc7351801c1f5900d37;hb=d9b85731ab7b965b1ae9bc1c283e39faf10a644a;hp=d5359019a4acf436cb3c8f621f2c55b8882efa16;hpb=3aa36f2aff049abbb012fab528183a189c06663f;p=idzebra-moved-to-github.git diff --git a/index/extract.c b/index/extract.c index d535901..593c9e8 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.150 2004-01-22 16:23:23 heikki Exp $ +/* $Id: extract.c,v 1.157 2004-07-28 09:47:41 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -23,6 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include +#include #ifdef WIN32 #include #else @@ -755,6 +756,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, char ext[128]; char ext_res[128]; struct file_read_info *fi; + const char *original_record_type = 0; if (!zh->m_group || !*zh->m_group) *gprefix = '\0'; @@ -774,6 +776,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, break; } /* determine file type - depending on extension */ + original_record_type = zh->m_record_type; if (!zh->m_record_type) { sprintf (ext_res, "%srecordType.%s", gprefix, ext); @@ -811,6 +814,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, if ((fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) { logf (LOG_WARN|LOG_ERRNO, "open %s", full_rep); + zh->m_record_type = original_record_type; return 0; } } @@ -823,6 +827,7 @@ int fileExtract (ZebraHandle zh, SYSNO *sysno, const char *fname, file_read_stop (fi); if (fd != -1) close (fd); + zh->m_record_type = original_record_type; return r; } @@ -1027,7 +1032,7 @@ int buffer_extract_record (ZebraHandle zh, extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys); rec_rm (&rec); logRecord(zh); - return 0; + return -1; } } @@ -1283,7 +1288,9 @@ void extract_flushRecordKeys (ZebraHandle zh, SYSNO sysno, if (zh->reg->key_buf_used + 1024 > (zh->reg->ptr_top -zh->reg->ptr_i)*sizeof(char*)) extract_flushWriteKeys (zh,0); + assert(zh->reg->ptr_i >= 0); ++(zh->reg->ptr_i); + assert(zh->reg->ptr_i > 0); (zh->reg->key_buf)[zh->reg->ptr_top - zh->reg->ptr_i] = (char*)zh->reg->key_buf + zh->reg->key_buf_used; #if SU_SCHEME @@ -1353,11 +1360,11 @@ void extract_flushWriteKeys (ZebraHandle zh, int final) qsort (zh->reg->key_buf + zh->reg->ptr_top - ptr_i, ptr_i, sizeof(char*), key_qsort_compare); - /* zebra.cfg: tempfiles: - /* Y: always use temp files (old way) */ - /* A: use temp files, if more than one (auto) */ - /* = if this is both the last and the first */ - /* N: never bother with temp files (new) */ + /* zebra.cfg: tempfiles: + Y: always use temp files (old way) + A: use temp files, if more than one (auto) + = if this is both the last and the first + N: never bother with temp files (new) */ temp_policy=toupper(res_get_def(zh->res,"tempfiles","auto")[0]); if (temp_policy != 'Y' && temp_policy != 'N' && temp_policy != 'A') { @@ -1478,6 +1485,10 @@ void extract_add_index_string (RecWord *p, const char *string, } dst = keys->buf + keys->buf_used; + /* leader byte is encoded as follows: + bit 0 : 1 if attrset is unchanged; 0 if attrset is changed + bit 1 : 1 if attruse is unchanged; 0 if attruse is changed + */ attrSet = p->attrSet; if (keys->buf_used > 0 && keys->prevAttrSet == attrSet) lead |= 1; @@ -1644,6 +1655,7 @@ static void extract_add_complete_field (RecWord *p) while (map && *map && **map == *CHR_SPACE) { remain = p->length - (b - p->string); + if (remain > 0) map = zebra_maps_input(p->zebra_maps, p->reg_type, &b, remain); else @@ -1658,10 +1670,17 @@ static void extract_add_complete_field (RecWord *p) { const char *cp = *map; - if (i >= IT_MAX_WORD) - break; - while (i < IT_MAX_WORD && *cp) - buf[i++] = *(cp++); + if (**map == *CHR_CUT) + { + i = 0; + } + else + { + if (i >= IT_MAX_WORD) + break; + while (i < IT_MAX_WORD && *cp) + buf[i++] = *(cp++); + } remain = p->length - (b - p->string); if (remain > 0) map = zebra_maps_input (p->zebra_maps, p->reg_type, &b,