Patch level : No patch on Main trunk

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Risolti conflitti


git-svn-id: svn://10.65.10.50/trunk@9216 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2000-10-02 08:18:04 +00:00
parent 5e3ed3ba8c
commit d41a2da1e2
2 changed files with 52 additions and 60 deletions

View File

@ -989,60 +989,52 @@ bool TCursor::has_simple_filter() const
TRecnotype TCursor::buildcursor(TRecnotype rp)
{
FILE* _f = open_index(TRUE);
const int handle = file().handle();
if (DB_reccount(handle) == 0)
{
close_index(_f);
return 0;
}
const int l = strlen(to());
int junk = DB_index_seek(handle, (char*)(const char*) from());
if (junk < 0) junk = get_error(junk);
if (junk == _iseof)
{
close_index(_f);
return 0;
}
TRecnotype oldrecno=0,ap = 0;
size_t pagecnt = 0;
int pagecnt = 0;
const bool filtered = has_filter();
FILE* _f = open_index(TRUE);
const int fhnd = file().handle();
if (DB_reccount(fhnd) == 0)
{
close_index(_f);
return 0;
}
fseek(_f, 0L, SEEK_SET);
const int l = strlen(to());
int junk = DB_index_seek(fhnd, (char*)(const char*) from());
if (junk < 0) junk=get_error(junk);
if (junk == _iseof) return 0;
TRecnotype* page = new TRecnotype [CMAXELPAGE];
// TRecnotype pos = DB_index_recno(handle);
// pos = DB_index_recno(fhnd);
_pos = -1;
DB_index_recno(fhnd);
_pos=-1;
const bool simple_filter = has_simple_filter();
while (TRUE)
{
if (DB_index_eof(handle)) break;
const char* s0 = DB_index_getkey(handle);
if (DB_index_eof(fhnd)) break;
const char* s0 = DB_index_getkey(fhnd);
if (l && (strncmp(to(), s0, l) < 0)) break;
const TRecnotype recno = DB_index_recno(handle);
const TRecnotype recno = DB_index_recno(fhnd);
if (recno == oldrecno) break; // means that no more keys are available
oldrecno=recno;
if (pagecnt == CMAXELPAGE)
{
if (filtered && !simple_filter)
pagecnt = filtercursor(pagecnt,page);
size_t written = fwrite(page, sizeof(TRecnotype), pagecnt, _f);
CHECKS(written == pagecnt, "Error writing index ", (const char*)_indexname);
if (_pos < 0)
{
for (size_t i= 0; i < pagecnt; i++)
if (page[i] == rp)
{
_pos = ap + i;
break;
}
}
fwrite(page,sizeof(TRecnotype),pagecnt,_f);
for (int i= 0; i< pagecnt; i++)
if (page[i] == rp)
{
_pos = ap + i;
break;
}
ap += pagecnt;
pagecnt = 0;
}
@ -1054,31 +1046,27 @@ TRecnotype TCursor::buildcursor(TRecnotype rp)
else
page[pagecnt++] = recno;
DB_index_next(handle);
int rt=get_error(-1);
DB_index_next(fhnd);
/*
int rt=get_error(-1); // Get Last Codebase Error
if (rt != NOERR)
fatal_box("Can't read index n. %d - file n. %d", DB_tagget(handle), file().num());
fatal_box("Can't read index n. %d - file n. %d",DB_tagget(fhnd), file().num());
*/
} // while
if (pagecnt)
{
if (filtered && !simple_filter)
pagecnt = filtercursor(pagecnt, page);
size_t written = fwrite(page, sizeof(TRecnotype), pagecnt, _f);
CHECKS(written == pagecnt, "Error writing index ", (const char*)_indexname);
if (_pos < 0)
{
for (size_t i = 0; i < pagecnt; i++)
if (page[i] == rp)
{
_pos = ap + i;
break;
}
}
fwrite(page, sizeof(TRecnotype), pagecnt, _f);
for (int i = 0; i < pagecnt; i++)
if (page[i] == rp)
{
_pos = ap + i;
break;
}
ap += pagecnt;
}
if (_pos == -1 && ap > 0)
_pos = 0;
delete page;
close_index(_f);
return ap;
@ -2832,10 +2820,14 @@ TSortedfile::TSortedfile(int logicnum, TRelation* rel, const char* ordexpr, cons
if (!rel)
_rel = new TRelation(logicnum);
else
_rel = rel;
_curs = new TSorted_cursor(_rel, ordexpr, "", nkey);
_rel=rel;
_curs = new TSorted_cursor(_rel,ordexpr,"",nkey);
_curs->setfilter(filter,TRUE); //BUG: cursors doesn't update rel.
if (&curr()!=&(_curs->file().curr()))
_curs->file().set_curr(&curr());
_curs->setfilter(filter,TRUE); //must pass TRUE because cursors doesn't update rel (BUG).
// DON't move this line BEFORE set_curr : filter's fieldrefs are allocated at cursor setfilter
}
// @mfunc Distruttore

View File

@ -98,10 +98,10 @@ void TString512::strncpy(const char* s, int n)
}
#ifdef FOXPRO
HIDDEN TString512 _spark;
HIDDEN TString512 spark;
#else
HIDDEN TString512* ptr_spark = new TString512;
HIDDEN TString512& _spark = *ptr_spark;
HIDDEN TString512& spark = *ptr_spark;
#endif
inline bool is_space(char c)