Resa const la variabile botime

git-svn-id: svn://10.65.10.50/trunk@184 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-09-07 17:00:25 +00:00
parent 60064f97d3
commit c48cfadb7d
11 changed files with 321 additions and 301 deletions

View File

@ -446,8 +446,8 @@ bool TApplication::set_firm(long newfirm)
enable_menu_item(M_FILE_NEW); enable_menu_item(M_FILE_NEW);
if (k == K_ENTER) if (k == K_ENTER)
{ {
newfirm = atol(mask.get(F_CODDITTA)); newfirm = mask.get_long(F_CODDITTA);
const int tipodir = atoi(mask.get(F_TIPO)); const int tipodir = mask.get_int(F_TIPO);
if (tipodir > 0) if (tipodir > 0)
{ {

View File

@ -12,7 +12,7 @@
#define DAYBIAS 36525L #define DAYBIAS 36525L
#define NULLDATE -99999L #define NULLDATE -99999L
TDate nodate, botime, eotime(31,12,2050); const TDate nodate, botime, eotime(31,12,2050);
HIDDEN TDate __tmp_date; HIDDEN TDate __tmp_date;
HIDDEN char __date_tmp_string[20]; HIDDEN char __date_tmp_string[20];

View File

@ -83,7 +83,7 @@ const char* itom(byte month); // Ritorna il nome del mese (1-12)
const char* itow(byte dayofweek); // Ritorna il nome del giorno (1-7) const char* itow(byte dayofweek); // Ritorna il nome del giorno (1-7)
// @DPUB // @DPUB
extern TDate nodate, botime, eotime; extern const TDate nodate, botime, eotime;
// @END // @END
#endif // __DATE_H #endif // __DATE_H

View File

@ -40,9 +40,6 @@
const int MAX_KEYS = 8; const int MAX_KEYS = 8;
// @END // @END
class TBaseisamfile;
class TExtrectype;
// @C // @C
// Classe TRectype : public TObject // Classe TRectype : public TObject
// //
@ -205,21 +202,21 @@ public:
virtual int next(TDate& atdate); virtual int next(TDate& atdate);
virtual int prev(word lockop = _nolock); virtual int prev(word lockop = _nolock);
virtual int prev(TDate& atdate); virtual int prev(TDate& atdate);
virtual int reread(word lockop = _nolock, TDate& atdate = botime); virtual int reread(word lockop = _nolock, TDate& atdate = (TDate&)botime);
virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = botime); virtual int reread(TRectype& rec, word lockop = _nolock, TDate& atdate = (TDate&)botime);
virtual int skip(TRecnotype nrec, word lockop = _nolock); virtual int skip(TRecnotype nrec, word lockop = _nolock);
virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = botime); virtual int read(word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime);
virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = botime); virtual int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& atdate = (TDate&)botime);
virtual int readat(TRecnotype nrec, word lockop = _nolock); virtual int readat(TRecnotype nrec, word lockop = _nolock);
virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); virtual int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
virtual int write(TDate& atdate = botime); virtual int write(TDate& atdate = (TDate&)botime);
virtual int write(const TRectype& rec, TDate& atdate = botime); virtual int write(const TRectype& rec, TDate& atdate = (TDate&)botime);
virtual int rewrite(TDate& atdate = botime); virtual int rewrite(TDate& atdate = (TDate&)botime);
virtual int rewrite(const TRectype& rec, TDate& atdate = botime); virtual int rewrite(const TRectype& rec, TDate& atdate = (TDate&)botime);
virtual int rewriteat(TRecnotype nrec); virtual int rewriteat(TRecnotype nrec);
virtual int rewriteat(const TRectype& rec, TRecnotype nrec); virtual int rewriteat(const TRectype& rec, TRecnotype nrec);
virtual int remove(TDate& atdate = botime); virtual int remove(TDate& atdate = (TDate&)botime);
virtual int remove(const TRectype& rec, TDate& atdate = botime); virtual int remove(const TRectype& rec, TDate& atdate = (TDate&)botime);
virtual const char* name() const; virtual const char* name() const;
TRecnotype recno() const { return _recno;} TRecnotype recno() const { return _recno;}

View File

@ -165,7 +165,8 @@ bool TPrefix::test(const char* s) const
{ {
if (s && *s && strcmp(s, "DEF")) if (s && *s && strcmp(s, "DEF"))
{ {
TString80 s1; s1 << __ptprf << s << "/dir.gen"; TString80 s1(__ptprf);
s1 << s << "/dir.gen";
if (!fexist(s1)) if (!fexist(s1))
return error_box("Impossibile trovare il file '%s'", (const char*)s1); return error_box("Impossibile trovare il file '%s'", (const char*)s1);
} }

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.6 1994-09-01 13:31:24 alex Exp $ // $Id: relation.cpp,v 1.7 1994-09-07 17:00:16 guy Exp $
// relation.cpp // relation.cpp
// fv 12/8/93 // fv 12/8/93
// relation class for isam files // relation class for isam files
@ -516,7 +516,7 @@ bool TRelation::next_match(int logicnum, const char* fieldlist, int nkey)
} }
// Riposiziona gli eventuali files successivi // Riposiziona gli eventuali files successivi
position_rels(_isequal, _nolock, botime, j+1); position_rels(_isequal, _nolock, (TDate&)botime, j+1);
reldef(j)->_first_match = FALSE; reldef(j)->_first_match = FALSE;
return ok; return ok;
@ -535,6 +535,9 @@ bool TRelation::is_first_match(int logicnum)
return err == NOERR; return err == NOERR;
} }
#ifdef DBG
bool TRelation::isconsistent(bool reset) bool TRelation::isconsistent(bool reset)
{ {
const int MAXREL = 24; const int MAXREL = 24;
@ -552,7 +555,7 @@ bool TRelation::isconsistent(bool reset)
if (bad) if (bad)
return _errors = bad; return _errors = bad;
position_rels(_isequal, _nolock, botime); position_rels(_isequal, _nolock, (TDate&)botime);
for (i = 0; i < _files.items(); i++) for (i = 0; i < _files.items(); i++)
if (file(i)->recno() != recnos[i]) if (file(i)->recno() != recnos[i])
{ {
@ -568,6 +571,9 @@ bool TRelation::isconsistent(bool reset)
return this->_errors = bad; return this->_errors = bad;
} }
#endif
int TRelation::write(bool force, TDate& atdate) int TRelation::write(bool force, TDate& atdate)
{ {
_errors = NOERR; _errors = NOERR;

View File

@ -1,4 +1,4 @@
/* $Id: relation.h,v 1.2 1994-08-26 14:06:07 alex Exp $ */ /* $Id: relation.h,v 1.3 1994-09-07 17:00:18 guy Exp $ */
// join.h // join.h
// fv 12/8/93 // fv 12/8/93
// join class for isam files // join class for isam files
@ -47,7 +47,7 @@ protected:
// adatto su un file, svuota il record corrente e non ritorna errore. // adatto su un file, svuota il record corrente e non ritorna errore.
// write etc. poi procedono normalmente // write etc. poi procedono normalmente
// @END // @END
int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = botime, int first = 0); int position_rels(TIsamop op = _isequal, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime, int first = 0);
friend class TCursor; friend class TCursor;
@ -62,7 +62,7 @@ public:
virtual int first(TReclock lockop = _nolock) { return file()->first(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int first(TReclock lockop = _nolock) { return file()->first(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int last(TReclock lockop = _nolock) { return file()->last(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int last(TReclock lockop = _nolock) { return file()->last(lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int skip(TRecnotype nrec, TReclock lockop = _nolock) { return file()->skip(nrec, lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); } virtual int skip(TRecnotype nrec, TReclock lockop = _nolock) { return file()->skip(nrec, lockop) == NOERR ? position_rels(_isequal, lockop) : file()->status(); }
virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime) { return file()->read(op, lockop, atdate) == NOERR ? position_rels(_isequal, lockop, atdate) : file()->status();} virtual int read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime) { return file()->read(op, lockop, atdate) == NOERR ? position_rels(_isequal, lockop, atdate) : file()->status();}
TLocalisamfile* lfile(int logicnum = 0) const; TLocalisamfile* lfile(int logicnum = 0) const;
TLocalisamfile* lfile(const char* name) const; TLocalisamfile* lfile(const char* name) const;
@ -88,9 +88,9 @@ public:
// @DES write methods // @DES write methods
// @FPUB // @FPUB
virtual int write (bool force = TRUE, TDate& atdate = botime); virtual int write (bool force = TRUE, TDate& atdate = (TDate&)botime);
virtual int rewrite(bool force = TRUE, TDate& atdate = botime); virtual int rewrite(bool force = TRUE, TDate& atdate = (TDate&)botime);
virtual int remove (TDate& atdate = botime); virtual int remove (TDate& atdate = (TDate&)botime);
// @DES checking methods // @DES checking methods
// @FPUB // @FPUB
@ -197,7 +197,7 @@ public:
TRectype& curr(int log = 0) const { return _if->curr(log); } TRectype& curr(int log = 0) const { return _if->curr(log); }
TRectype& curr(const char * tab) const TRectype& curr(const char * tab) const
{ return _if->lfile(tab)->curr(); } { return _if->lfile(tab)->curr(); }
TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = botime); TRecnotype read(TIsamop op = _isgteq, TReclock lockop = _nolock, TDate& atdate = (TDate&)botime);
virtual bool ok() const; virtual bool ok() const;
const char* filter() const { return _filter; } const char* filter() const { return _filter; }

View File

@ -16,7 +16,7 @@
#include <utility.h> #include <utility.h>
HIDDEN const int MAXSTR = 257; HIDDEN const int MAXSTR = 301;
HIDDEN char __spark[MAXSTR]; // Utility buffer HIDDEN char __spark[MAXSTR]; // Utility buffer
TFixed_string spark(__spark, MAXSTR); TFixed_string spark(__spark, MAXSTR);
@ -54,7 +54,7 @@ int TString::make_room(int s)
const int lun = len(); const int lun = len();
const int spare = size() - lun; const int spare = size() - lun;
if (spare < s) if (spare < s)
resize(size() + 2*s, TRUE); resize(size() + 2*s, TRUE); // Melius abundare ...
return lun; return lun;
} }
@ -97,7 +97,7 @@ TString& TString::operator <<(char c)
TString& TString::operator <<(int n) TString& TString::operator <<(int n)
{ {
const int pos = make_room(6); const int pos = make_room(8);
sprintf(&_str[pos], "%d", n); sprintf(&_str[pos], "%d", n);
return *this; return *this;
} }
@ -215,8 +215,7 @@ bool TString::match(const char* s) const
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
HIDDEN char* strstr(const char* string1, const char* string2) HIDDEN char* strstr(const char* string1, const char* string2)
{ {
int len = strlen(string2); const int len = strlen(string2);
while (*string1) while (*string1)
{ {
if (strncmp(string1, string2, len) == 0) return (char*) string1; if (strncmp(string1, string2, len) == 0) return (char*) string1;
@ -258,13 +257,13 @@ const char* TString::mid(int from, int count) const
{ {
const int l = len(); const int l = len();
#ifdef DBG
if (from < 0) if (from < 0)
{ {
#ifdef DBG
error_box("Ivalid MID parameter: from = %d", from); error_box("Ivalid MID parameter: from = %d", from);
#endif
from = 0; from = 0;
} }
#endif
if (from > l) from = l; if (from > l) from = l;
if (count < 1) count = l-from; if (count < 1) count = l-from;
@ -274,7 +273,7 @@ const char* TString::mid(int from, int count) const
} }
// Certified 90% (uses mid) // Certified 100% (uses mid)
const char* TString::sub(int from, int to) const const char* TString::sub(int from, int to) const
{ {
const int count = to-from; const int count = to-from;
@ -346,7 +345,7 @@ TString& TString::trim()
return *this; return *this;
} }
// Certified 99% // Certified 100%
TString& TString::fill(char c, int n) TString& TString::fill(char c, int n)
{ {
if (n < 0) n = size(); else if (n < 0) n = size(); else
@ -356,7 +355,7 @@ TString& TString::fill(char c, int n)
return *this; return *this;
} }
// Certified 100%
TString& TString::right_just(int n, char c) TString& TString::right_just(int n, char c)
{ {
if (n < 0) n = size(); if (n < 0) n = size();
@ -368,6 +367,7 @@ TString& TString::right_just(int n, char c)
return *this; return *this;
} }
// Certified 100%
TString& TString::center_just(int n, char c) TString& TString::center_just(int n, char c)
{ {
if (n < 0) n = size(); if (n < 0) n = size();
@ -380,6 +380,7 @@ TString& TString::center_just(int n, char c)
return *this; return *this;
} }
// Certified 100%
TString& TString::left_just(int n, char c) TString& TString::left_just(int n, char c)
{ {
if (n < 0) n = size(); if (n < 0) n = size();
@ -418,7 +419,7 @@ TString& TString::format(const char* fmt, ...)
const int tot = vsprintf(__spark, fmt, pars); const int tot = vsprintf(__spark, fmt, pars);
va_end(pars); va_end(pars);
CHECK(tot >= 0 && tot < sizeof(__spark)-1, "Ue'! Quanto scrivi?"); CHECK(tot >= 0 && tot < spark.size(), "Ue'! Quanto scrivi?");
if (tot > size()) resize(tot, FALSE); if (tot > size()) resize(tot, FALSE);
strcpy(_str, __spark); strcpy(_str, __spark);
@ -489,7 +490,7 @@ word TString::hash() const
TFixed_string::TFixed_string(const char* str, int size) TFixed_string::TFixed_string(const char* str, int size)
: TString((char*)str, (size < 1) ? strlen(str) : size-1) : TString((char*)str, (size < 1) ? strlen(str) : size-1)
{ {
if (size > 0 && memchr(str, 0, size) == NULL) if (size > 0 && memchr(str, '\0', size) == NULL)
cut(0); cut(0);
} }
@ -503,8 +504,7 @@ TFixed_string::~TFixed_string()
void TFixed_string::resize(int size, bool) void TFixed_string::resize(int size, bool)
{ {
#ifdef DBG #ifdef DBG
fatal_box("Impossibile ridimensionare una stringa fissa da %d a %d", fatal_box("Impossibile ridimensionare una stringa fissa da %d a %d", _size, size);
_size, size);
#endif #endif
} }
@ -517,6 +517,20 @@ void TFixed_string::strncpy(const char* s, int n)
_str[i] = '\0'; _str[i] = '\0';
} }
// Certified 99%
// More efficient than TString::format, it does not use spark
TString& TFixed_string::format(const char* fmt, ...)
{
va_list pars;
va_start(pars, fmt);
const int tot = vsprintf(_str, fmt, pars);
va_end(pars);
CHECK(tot >= 0 && tot < size(), "Ue'! Quanto scrivi?");
return *this;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Filename // Filename
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -625,7 +639,7 @@ TToken_string::TToken_string(const char* s, char separator)
// Certified 100% // Certified 100%
TToken_string::TToken_string(int n, char separator) TToken_string::TToken_string(int n, char separator)
: TString(n), _separator(separator), _last(-2) : TString(n), _separator(separator), _last(0)
{} {}
@ -662,7 +676,6 @@ const char* TToken_string::get()
{ {
const int k = find(_separator, start); const int k = find(_separator, start);
_last = (k >= 0) ? k+1 : -1; _last = (k >= 0) ? k+1 : -1;
if (k)
return sub(start, k); return sub(start, k);
} }
return ""; return "";
@ -671,15 +684,13 @@ const char* TToken_string::get()
// Certified 50% // Certified 50%
const char* TToken_string::get(int n) const char* TToken_string::get(int n)
{ {
if (_last == -2) return NULL;
if (n < 0) if (n < 0)
{ {
if (n == -2) if (n == -2)
{ {
const char* sep = strrchr(_str, _separator); const char* sep = strrchr(_str, _separator);
_last = -1; _last = -1;
return sep ? sep+1 : NULL; return sep ? sep+1 : _str;
} }
else return get(); else return get();
} }
@ -732,7 +743,7 @@ int TToken_string::get_int(int n)
long TToken_string::get_long(int n) long TToken_string::get_long(int n)
{ {
const char* num = get(n); const char* num = get(n);
return num ? atol(num) : 0; return num ? atol(num) : 0L;
} }
@ -785,9 +796,13 @@ bool TToken_string::empty_items() const
// Certified 80% // Certified 80%
int TToken_string::items() const int TToken_string::items() const
{ {
if (_last == -2 || empty()) return 0; int t = 0;
int t = 1; if (not_empty())
for (const char* s = _str; *s; s++) if (*s == _separator) t++; {
t++;
for (const char* s = _str; *s; s++)
if (*s == _separator) t++;
}
return t; return t;
} }

View File

@ -92,7 +92,7 @@ public:
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra
TString& picture(const char* pic, const char* s); TString& picture(const char* pic, const char* s);
TString& format(const char* fmt, ...); virtual TString& format(const char* fmt, ...);
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima. TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
@ -142,9 +142,10 @@ public:
TFixed_string(const char* str, int size = -1); TFixed_string(const char* str, int size = -1);
virtual ~TFixed_string(); virtual ~TFixed_string();
virtual TString& format(const char* fmt, ...);
const TString& operator =(const TString& s) { return set((const char*)s); } const TString& operator =(const TString& s) { return set((const char*)s); }
const TString& operator=(const char* s) { return set(s); } const TString& operator=(const char* s) { return set(s); }
void strncpy(const char* s, int n); void strncpy(const char* s, int n);
}; };

View File

@ -64,14 +64,15 @@ int TTable::last(word lockop)
int TTable::next(word lockop) int TTable::next(word lockop)
{ {
TRecfield codtab(curr(), "CODTAB"); TRecfield codtab(curr(), "CODTAB");
const TRecnotype nrec = recno();
if (nrec != filehnd()->RecNo)
{
read(); read();
if (bad()) return status(); if (bad()) return status();
}
TRecnotype nrec = recno();
TBaseisamfile::next(lockop); TBaseisamfile::next(lockop);
const char *c = (const char *) codtab; const char *c = (const char *) codtab;
@ -87,7 +88,6 @@ int TTable::next(word lockop)
int TTable::prev(word lockop) int TTable::prev(word lockop)
{ {
TRecfield codtab(curr(), "CODTAB"); TRecfield codtab(curr(), "CODTAB");

View File

@ -30,19 +30,19 @@ public:
int last(word lockop = _nolock); int last(word lockop = _nolock);
int next(word lockop = _nolock); int next(word lockop = _nolock);
int prev(word lockop = _nolock); int prev(word lockop = _nolock);
int reread(word lockop = _nolock, TDate& = botime); int reread(word lockop = _nolock, TDate& = (TDate&)botime);
int reread(TRectype& rec, word lockop = _nolock, TDate& = botime); int reread(TRectype& rec, word lockop = _nolock, TDate& = (TDate&)botime);
int skip(TRecnotype nrec, word lockop = _nolock); int skip(TRecnotype nrec, word lockop = _nolock);
int read(word op = _isequal, word lockop = _nolock, TDate& = botime); int read(word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& = botime); int read(TRectype& rec, word op = _isequal, word lockop = _nolock, TDate& = (TDate&)botime);
int readat(TRecnotype nrec, word lockop = _nolock); int readat(TRecnotype nrec, word lockop = _nolock);
int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock); int readat(TRectype& rec, TRecnotype nrec, word lockop = _nolock);
int write(TDate& = botime); int write(TDate& = (TDate&)botime);
int write(const TRectype& rec, TDate& = botime); int write(const TRectype& rec, TDate& = (TDate&)botime);
int rewrite(TDate& = botime); int rewrite(TDate& = (TDate&)botime);
int rewrite(const TRectype& rec, TDate& = botime); int rewrite(const TRectype& rec, TDate& = (TDate&)botime);
int remove(TDate& = botime); int remove(TDate& = (TDate&)botime);
int remove(const TRectype& rec, TDate& = botime); int remove(const TRectype& rec, TDate& = (TDate&)botime);
virtual const char* name() const { return (const char*) _tabname;} virtual const char* name() const { return (const char*) _tabname;}