Patch level : 10.0

Files correlati     : agalib.lib
Ricompilazione Demo : [ ]
Commento            :
Tolte riscritture inutili in codebase


git-svn-id: svn://10.65.10.50/trunk@16106 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-02-05 15:32:58 +00:00
parent 20c8916d26
commit dd42418ad6
2 changed files with 22 additions and 38 deletions

View File

@ -44,7 +44,7 @@ bool handle_ok(int handle)
dbdata[handle] != NULL && dbdata[handle]->clientId >= 0;
}
static char* find_slash_backslash(const char* s)
static const char* find_slash_backslash(const char* s)
{
const char* slash = NULL;
for ( ; *s; s++)
@ -52,7 +52,7 @@ static char* find_slash_backslash(const char* s)
if (*s == '\\' || *s == '/')
slash = s;
}
return (char*)slash;
return slash;
}
@ -66,7 +66,11 @@ void DB_init(void)
memset(dbdata, 0, sizeof(dbdata));
code4init(&code_base);
code4unlockAutoSet(&code_base, LOCK4DATA /*LOCK4OFF*/ ); // Pensiamoci dalla 4.0
// Nella 3.0 il default LOCK4DATA e' stato messo nella DLL per non ridistribuire tutto.
// Nelle versioni succesive la DLL e' "intonsa" ed ha un default diverso deciso da Codebase.
// Per cui ora forziano LOCK4DATA (anche se considerato deprecated)
// in quanto non funziona bene LOCK4RECORD (che sarebbe quello giusto)
code4unlockAutoSet(&code_base, LOCK4DATA);
code_base.readLock=0;
code_base.errDefaultUnique=e4unique;
code_base.safety=0;
@ -400,12 +404,7 @@ int DB_rewrite(int handle)
if(!handle_ok(handle)) return(-1);
while ((rt=d4write(dbdata[handle],d4recNo(dbdata[handle]))) == r4locked)
u4delaySec();
if (rt == 0)
{
/* while ((rt = d4flush(dbdata[handle])) == r4locked)
u4delaySec(); */
rt = DB_flush(handle);
}
if (rt == e4unique)
{
char msg[256];
@ -428,19 +427,10 @@ int DB_rewrite(int handle)
int DB_add(int handle)
{
int rt;
/* int is_locked = 0; */
DATA4 * data = dbdata[handle];
if (data==0) return(-1);
/*
is_locked = DB_file_locked(handle);
if (is_locked == 0) // Se non e' stato gia' bloccato in modo esclusivo
{
while (d4lockAll(data) == r4locked)
u4delaySec();
}
*/
while ((rt = d4appendStart(data,0)) == r4locked)
u4delaySec();
if (rt == 0)
@ -464,18 +454,12 @@ int DB_add(int handle)
rt = _isreinsert;
}
else
if (rt == 0) //&& is_locked == 0)
{
while ((rt = d4flush(data)) == r4locked)
u4delaySec();
if (rt == 0)
rt = DB_flush(handle);
}
}
/*
if (is_locked == 0)
DB_unlock(handle);
*/
return(rt);
}
@ -492,7 +476,7 @@ int DB_lockfile(int handle)
return(rt);
}
HIDDEN void do_key(char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
HIDDEN void do_key(const char *fname, RecDes *r, TAG4INFO *tag_info, int n_keys)
{
int i,j;
char tiname[_MAX_FNAME]; /* Tag name, max 8 characters long! */
@ -666,7 +650,7 @@ int DB_packmemo(short vis, const char * filename)
/*-------------------------------------------------------------------------
Elimina i record duplicati
--------------------------------------------------------------------------*/
int DB_clean_file(int handle, char * filename, char * ff, RecDes * r, short vis)
static int DB_clean_file(int handle, const char* filename, const char* ff, RecDes* r, short vis)
{
TAG4INFO tags[2];
TAG4 * t;
@ -745,11 +729,11 @@ int DB_packindex(short vis, const char * filename, RecDes *r, long *peod, bool a
if (handle >= 0)
{
int i;
char *ff = find_slash_backslash(filename);
const char *ff = find_slash_backslash(filename);
if (vis)
progind_create((long)r->NKeys,s,0,1,60);
if ((ff == NULL) || *ff == '\0')
ff = (char *)filename;
ff = filename;
else
ff++;
do_key(ff,r,tags, r->NKeys);
@ -764,7 +748,7 @@ int DB_packindex(short vis, const char * filename, RecDes *r, long *peod, bool a
{
rt = 0;
if (!ask || DB_yesnobox("Sono stati rilevati alcuni records duplicati:\nsi desidera eliminarli?"))
rt = DB_clean_file(handle, (char*) filename, ff, r, vis);
rt = DB_clean_file(handle, filename, ff, r, vis);
else
tags[0].unique = r4unique_continue;
if (rt == 0)
@ -824,7 +808,7 @@ int DB_build(const char * filename, RecDes *r)
TAG4INFO tag_info[MaxKeys+1]; /* Numero di chiavi in un file */
DATA4 *dbuilded;
int rt=0,i;
char *ff = find_slash_backslash(filename);
const char *ff = find_slash_backslash(filename);
for (i=0; ((i<r->NFields) && (i<MaxFields)); i++) /* Construct field_info */
@ -1174,9 +1158,9 @@ char* DB_memoptr( const int handle, const char * fieldname )
int DB_memowrite( const int handle, const char* fieldname, const char* data )
{
FIELD4* f = d4field(dbdata[handle], fieldname );
int ret = f4memoAssign( f, (char*)data );
int ret = f4memoAssign( f, data );
if (ret == 0) // && !DB_file_locked(handle))
if (ret == 0)
{
d4flush(dbdata[handle]);
d4unlock(dbdata[handle]);

View File

@ -2176,9 +2176,9 @@ int TSystemisamfile::update(
const TRecnotype nitems = items();
#ifdef DBG
TProgind p(nitems > 0 ? nitems : 1, s, true, true, 78);
TProgind p(nitems > 0 ? nitems : 1, s, true, true);
#else
TProgind p(nitems > 0 ? nitems : 1, s, false, true, 78);
TProgind p(nitems > 0 ? nitems : 1, s, false, true);
#endif
TExtrectype nrec(wrec);