From 12f4ee0441b0bff4f3aac4b6853010617b50f9a9 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 20 Dec 1996 12:09:45 +0000 Subject: [PATCH] applicat.cpp Tolti include inutili codeb.c Sostituita la x4go con la d4go isam.cpp Tolta una riga vuota maskfld.cpp Aggiunto controllo sugli id duplicati relation.cpp Aggiunto test di cancellato nel metodo TCursor::changed realtion.h Aggiunto const al metodo TFieldref::len git-svn-id: svn://10.65.10.50/trunk@4027 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/applicat.cpp | 9 +++----- include/isam.cpp | 1 - include/maskfld.cpp | 6 +++-- include/relation.cpp | 55 +++++++++++++++++++++++++------------------- include/relation.h | 2 +- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/include/applicat.cpp b/include/applicat.cpp index e4bc6c68c..b81a91423 100755 --- a/include/applicat.cpp +++ b/include/applicat.cpp @@ -4,8 +4,6 @@ #define XVT_INCL_NATIVE #include -#include - #if XVT_OS == XVT_OS_WIN #include #endif @@ -13,17 +11,16 @@ #include #include #include +#include +#include #include +#include #include #include -#include -#include -#include #include #include #include #include -#include #include diff --git a/include/isam.cpp b/include/isam.cpp index 783af6e7d..b2691d609 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -516,7 +516,6 @@ HIDDEN int cisread(isfdptr isfd, TRectype & record, int mode) HIDDEN int delkeys(isfdptr fd, char* record,long recno) { int rt=NOERR,oldkey = fd->knum; - for (int i=1; i<=fd->r->NKeys;i++) { diff --git a/include/maskfld.cpp b/include/maskfld.cpp index 7dad9a487..bbdbec3ce 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -267,12 +267,14 @@ void TMask_field::construct(TScanner& scanner, WINDOW parent) parse_head(scanner); scanner.popkey(); // BEGIN -#ifdef DBG +#ifdef DBG if (scanner.key() != "BE") { - yesnofatal_box("Testata errata o BEGIN mancante nel campo %d", _ctl_data._dlg); + NFCHECK("Testata errata o BEGIN mancante nel campo %d", _ctl_data._dlg); scanner.push(); } + if (_ctl_data._dlg > 0 && mask().id2pos(_ctl_data._dlg) >= 0) + NFCHECK("Esistono due campi con identificatore %d", _ctl_data._dlg); #endif while(scanner.popkey() != "EN") // END of control diff --git a/include/relation.cpp b/include/relation.cpp index 1ea2141d3..51beeb5ce 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -436,7 +436,7 @@ void TRelation::write_enable( // @syntax void write_enable(const char* name, const bool on) // // @comm Nel caso venga passato un numero logico uguale a 0 vengono abilitati/disabilitati tutti -// i file dell relazione +// i file della relazione { @@ -881,10 +881,11 @@ bool TRelation::exist(int logicnum) const HIDDEN bool __evalcondition(const TRelation& r,TExpression* cond) { + TFieldref f; for (int i = cond->numvar() - 1; i >= 0; i--) { - const char* s = cond->varname(i); - TFieldref f(s,0); + const TFixed_string s(cond->varname(i)); + f = s; cond->setvar(i, f.read(r)); } return (bool) *cond; @@ -1040,14 +1041,12 @@ bool TCursor::ok() const } bool TCursor::changed() - { isdef* fh = file().filehnd(); - - if (_frozen && _lastrec > 0L) return _filename != fh->d->SysName; + if (_frozen && _lastrec > 0L) + return _filename != fh->d->SysName; const TRecnotype eod = DB_reccount(fh->fhnd); - if (_lastrec != eod || (_lastkrec != DB_changed(fh->fhnd)) || (_filename != fh->d->SysName)) @@ -1057,7 +1056,11 @@ bool TCursor::changed() // _lastkrec = DB_changed(fh->fhnd); return TRUE; } - else return FALSE; + + if (!curr().valid()) + return TRUE; + + return FALSE; } TRecnotype TCursor::update() @@ -1099,7 +1102,7 @@ void TCursor::filter( if (file().tab()) { - TTable& f = (TTable&) file(); + const TTable& f = (const TTable&)file(); kf = kto = f.name(); } if (from != NULL) @@ -1253,7 +1256,8 @@ TRecnotype TCursor::read(TIsamop op, TReclock lockop, TDate& atdate) TCursor::TCursor(TRelation* r, const char* fil, int nkey, const TRectype *from, const TRectype* to) -: _if(r), _nkey(nkey), _frozen(FALSE), _filterfunction(NULL), _fexpr(NULL), _filter_update(FALSE), _filterfunction_update(FALSE) + : _if(r), _nkey(nkey), _frozen(FALSE), _filterfunction(NULL), _fexpr(NULL), + _filter_update(FALSE), _filterfunction_update(FALSE) { file().setkey(_nkey); _pos = 0; @@ -1275,7 +1279,6 @@ TCursor::~TCursor() TRecnotype TCursor::readrec() - { TRecnotype& nrec = file().filehnd()->RecNo; @@ -1362,8 +1365,12 @@ TRecnotype TCursor::items() bool TCursor::next_match(int lognum, const char* fl, int nk) { if (lognum == 0 || lognum == file().num()) - {++(*this); return file().good(); } - else return _if->next_match(lognum, fl, nk); + { + ++(*this); + return file().good(); + } + else + return _if->next_match(lognum, fl, nk); } bool TCursor::is_first_match(int ln) @@ -1403,7 +1410,7 @@ bool TSorted_cursor::check_expr( int rt=TRUE; if (p>-1 && p1>-1) - if (s.find("UPPER") == -1) + if (s.find("UPPER") < 0) { error_box("Only UPPER() operator is allowed"); rt=FALSE; @@ -1432,7 +1439,7 @@ bool TSorted_cursor::is_upper(TString& s) // Controlla se nell'espressione esiste l'operatore UPPER() { bool rt=TRUE; - if (s.find("UPPER")>-1) + if (s.find("UPPER") >= 0) rt=check_expr(s); else rt=FALSE; @@ -1552,7 +1559,6 @@ TRecnotype TSorted_cursor::buildcursor(TRecnotype rp) int TSorted_cursor::filtercursor(int pagecnt, TRecnotype* page) { - int np=0, handle=file().filehnd()->fhnd; TRectype& rec=file().curr(); TString s; @@ -1613,11 +1619,12 @@ bool TSorted_cursor::changed() rt = TCursor::changed(); if (!rt) rt=_is_changed_expr; _is_changed_expr = FALSE; - } else - { - error_box("Can't perform changed() while expression ain't valid!"); - rt=FALSE; - } + } + else + { + NFCHECK("Can't perform changed() while expression is not valid!"); + rt=FALSE; + } return rt; } @@ -1627,7 +1634,7 @@ void TSorted_cursor::change_order(const char* order_expr) if (order_expr && *order_expr && order_expr != _order_expr) { TString s; - _order_expr = order_expr; + _order_expr = order_expr; _order_expr.restart(); while ((s=_order_expr.get()).not_empty() && (_is_valid_expr=check_expr(s))) ; if (_is_valid_expr) @@ -1776,7 +1783,7 @@ void TFieldref::print_on(ostream& out) const const char* TFieldref::read(const TRectype& rec) const { - static TString256 buffer; + static TString buffer; if (_fileid >= CNF_GENERAL) { @@ -1827,7 +1834,7 @@ void TFieldref::write(const char* val, TRectype& rec) const } } -int TFieldref::len(TRectype &rec) const +int TFieldref::len(const TRectype &rec) const { if (_to >= 0) return _to - _from; diff --git a/include/relation.h b/include/relation.h index 1e051ebfa..f00447c8f 100755 --- a/include/relation.h +++ b/include/relation.h @@ -535,7 +535,7 @@ public: int to() const { return _to; } // @cmember Ritorna la lunghezza del campo di

- int len(TRectype &rec) const; + int len(const TRectype &rec) const; // @cmember Cerca nella relazione il campo e ne ritorna il contenuto const char* read(const TRelation&) const; // @cmember Cerca nel record il campo e ne ritorna il contenuto