diff --git a/include/files.cpp b/include/files.cpp index 7b6d000ba..6120e4ded 100755 --- a/include/files.cpp +++ b/include/files.cpp @@ -13,6 +13,7 @@ #endif #include +#include #define BLOCKLEN 512 #define INVFLD 255 @@ -366,7 +367,41 @@ TTrec::~TTrec () int TTrec::compare(const TSortable & a) const { const TTrec & r = (const TTrec &) a; - const int res = memcmp ((const void *) _rec, (const void *) r._rec, sizeof (*_rec)); + int res = 0; + + if (_rec->NFields != r._rec->NFields || _rec->NKeys != r._rec->NKeys) // Confronta prima il numero dei campi o il numero delle chiavi + res = 1; + else + { + const int nkeys = _rec->NKeys; + for (int i=0; iKy[i]; + const KeyDes& k2 = r._rec->Ky[i]; + if (k1.DupKeys != k2.DupKeys || k1.NkFields != k2.NkFields) + res = 1; + else + for (int j=0; jNFields; + for (int n=0; nFd[n]; + const RecFieldDes& r2 = r._rec->Fd[n]; + if (r1.TypeF != r2.TypeF || r1.Len != r2.Len || r1.Dec != r2.Dec) + res = 1; + else + if (strcmp(r1.Name,r2.Name) != 0) + res = 1; + } + } + } return res; } @@ -570,7 +605,7 @@ void TTrec::update_keydef (int key, const char *desc) _rec->Ky[key].FieldSeq[n] = i; _rec->Ky[key].FromCh[n] = INVFLD; - _rec->Ky[key].FromCh[n] = INVFLD; + _rec->Ky[key].ToCh[n] = INVFLD; inst = c.step (); sym = inst.getsym (); if (sym == _upper) @@ -596,7 +631,7 @@ void TTrec::print_on (ostream & out) const { const int n = num(); out << n; - if (_des && n>=3 && n<=5) // Solo se e' una tabella... + if (_des && n>=LF_TABGEN && n<=LF_TAB && _tab.not_empty()) // Solo se e' una tabella... out << "|" << _tab; out << '\n'; const int nfields = fields (); @@ -628,7 +663,7 @@ void TTrec::read_from (istream & in) const int n = num(); in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n'); - if (_des && n>=3 && n<=5) + if (_des && n>=LF_TABGEN && n<=LF_TAB) { TString t(_files_tmp_string); diff --git a/include/files.h b/include/files.h index c40313b3b..a087e17b8 100755 --- a/include/files.h +++ b/include/files.h @@ -244,7 +244,7 @@ public: const char* keydef(int key) const; // @cmember Ritorna la lunghezza del record int len() const - { return _rec->Fd[fields() - 1].RecOff + _rec->Fd[fields() - 1].Len; } + { return fields() > 0 ? _rec->Fd[fields() - 1].RecOff + _rec->Fd[fields() - 1].Len : 0; } #ifndef FOXPRO // @cmember Aggiorna la chiave.

e' una token string