Commentata parte inutile o incompatibile per FOXPRO
git-svn-id: svn://10.65.10.50/trunk@43 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
224ec2c260
commit
76f5246fab
@ -1,14 +1,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <files.h>
|
#include <files.h>
|
||||||
|
|
||||||
|
#ifndef FOXPRO
|
||||||
#include <expr.h>
|
#include <expr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __EXTCDECL_H
|
#ifndef __EXTCDECL_H
|
||||||
#include <extcdecl.h>
|
#include <extcdecl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <strings.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
#define BLOCKLEN 512
|
#define BLOCKLEN 512
|
||||||
@ -99,11 +103,11 @@ write (char *record, TRecnotype recnum, TReclock lock)
|
|||||||
|
|
||||||
int TFile ::
|
int TFile ::
|
||||||
status ()
|
status ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _file->IOR;
|
return _file->IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDir ::
|
TDir ::
|
||||||
TDir ()
|
TDir ()
|
||||||
@ -124,49 +128,49 @@ TDir ::~TDir ()
|
|||||||
|
|
||||||
const char *TDir ::
|
const char *TDir ::
|
||||||
name ()
|
name ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->SysName;
|
return _dir->SysName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TDir ::des ()
|
const char *TDir ::des ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->Des;
|
return _dir->Des;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TDir ::expr ()
|
const char *TDir ::expr ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->FCalc;
|
return _dir->FCalc;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRecnotype & TDir ::
|
TRecnotype & TDir ::
|
||||||
eod ()
|
eod ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->EOD;
|
return _dir->EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRecnotype & TDir ::
|
TRecnotype & TDir ::
|
||||||
eox ()
|
eox ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->EOX;
|
return _dir->EOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRecnotype & TDir ::
|
TRecnotype & TDir ::
|
||||||
flags ()
|
flags ()
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return _dir->Flags;
|
return _dir->Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
word & TDir ::
|
word & TDir ::
|
||||||
len ()
|
len ()
|
||||||
@ -177,13 +181,13 @@ len ()
|
|||||||
|
|
||||||
int TDir ::
|
int TDir ::
|
||||||
status (TDirtype dirop)
|
status (TDirtype dirop)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return fdir[dirop].IOR;
|
return fdir[dirop].IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDir ::set_len (const UINT16 len)
|
void TDir ::set_len (const UINT16 len)
|
||||||
{
|
{
|
||||||
_dir->LenR = len;
|
_dir->LenR = len;
|
||||||
}
|
}
|
||||||
@ -240,15 +244,15 @@ zero ()
|
|||||||
|
|
||||||
int TDir ::
|
int TDir ::
|
||||||
items (TDirtype dirtype)
|
items (TDirtype dirtype)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
FileDes f;
|
FileDes f;
|
||||||
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
|
||||||
|
|
||||||
CGetFile (1, &f, _nolock, _whichdir);
|
CGetFile (1, &f, _nolock, _whichdir);
|
||||||
return (int) f.EOD;
|
return (int) f.EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTrec ::
|
TTrec ::
|
||||||
TTrec ()
|
TTrec ()
|
||||||
@ -269,15 +273,15 @@ TTrec ::~TTrec ()
|
|||||||
|
|
||||||
int TTrec ::
|
int TTrec ::
|
||||||
compare (const TSortable & a)
|
compare (const TSortable & a)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
const TTrec & r = (const TTrec &) a;
|
const TTrec & r = (const TTrec &) a;
|
||||||
const int res = memcmp ((const void *) _rec, (const void *) r._rec, sizeof (*_rec));
|
const int res = memcmp ((const void *) _rec, (const void *) r._rec, sizeof (*_rec));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec ::rehash ()
|
void TTrec ::rehash ()
|
||||||
|
|
||||||
{
|
{
|
||||||
setrdes (_rec);
|
setrdes (_rec);
|
||||||
@ -321,56 +325,59 @@ zero ()
|
|||||||
|
|
||||||
int TTrec ::
|
int TTrec ::
|
||||||
status (TDirtype dirop)
|
status (TDirtype dirop)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return rdir[dirop].IOR;
|
return rdir[dirop].IOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TTrec ::field (const char *name)
|
int TTrec ::field (const char *name)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
return findfld (_rec, (char *) name);
|
return findfld (_rec, (char *) name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TTrec ::fielddef (int fld)
|
const char *TTrec ::fielddef (int fld)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
|
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
|
||||||
(int) _rec->Fd[fld].TypeF, (int) _rec->Fd[fld].Len,
|
(int) _rec->Fd[fld].TypeF, (int) _rec->Fd[fld].Len,
|
||||||
(int) _rec->Fd[fld].Dec);
|
(int) _rec->Fd[fld].Dec);
|
||||||
return _files_tmp_string;
|
return _files_tmp_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *TTrec ::keydef (int key)
|
const char *TTrec ::keydef (int key)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
TFixed_string s (_files_tmp_string, 128);
|
TFixed_string s (_files_tmp_string, 128);
|
||||||
|
|
||||||
s = "";
|
s = "";
|
||||||
for (int j = 0; j < _rec->Ky[key].NkFields; j++)
|
for (int j = 0; j < _rec->Ky[key].NkFields; j++)
|
||||||
{
|
{
|
||||||
const bool upper = _rec->Ky[key].FieldSeq[j] > MaxFields;
|
const bool upper = _rec->Ky[key].FieldSeq[j] > MaxFields;
|
||||||
const int nfld = _rec->Ky[key].FieldSeq[j] - (upper ? MaxFields : 0);
|
const int nfld = _rec->Ky[key].FieldSeq[j] - (upper ? MaxFields : 0);
|
||||||
|
|
||||||
if (j)
|
if (j)
|
||||||
s << "+";
|
s << "+";
|
||||||
if (upper)
|
if (upper)
|
||||||
s << "UPPER(";
|
s << "UPPER(";
|
||||||
s << _rec->Fd[nfld].Name;
|
s << _rec->Fd[nfld].Name;
|
||||||
if (_rec->Ky[key].FromCh[j] < INVFLD)
|
if (_rec->Ky[key].FromCh[j] < INVFLD)
|
||||||
s << format ("[%d,%d]", _rec->Ky[key].FromCh[j] + 1,
|
s << format ("[%d,%d]", _rec->Ky[key].FromCh[j] + 1,
|
||||||
_rec->Ky[key].ToCh[j] + 1);
|
_rec->Ky[key].ToCh[j] + 1);
|
||||||
if (upper)
|
if (upper)
|
||||||
s << ")";
|
s << ")";
|
||||||
}
|
}
|
||||||
s << (_rec->Ky[key].DupKeys ? "|X" : "| ");
|
s << (_rec->Ky[key].DupKeys ? "|X" : "| ");
|
||||||
return (const char *) s;
|
return (const char *) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FOXPRO
|
||||||
|
|
||||||
void TTrec ::
|
void TTrec ::
|
||||||
update_fielddef (int nfld, const char *desc)
|
update_fielddef (int nfld, const char *desc)
|
||||||
@ -392,71 +399,71 @@ update_keydef (int key, const char *desc)
|
|||||||
TString ke (s.get ());
|
TString ke (s.get ());
|
||||||
|
|
||||||
if (expr.set ((const char *) ke, _strexpr))
|
if (expr.set ((const char *) ke, _strexpr))
|
||||||
|
{
|
||||||
|
_rec->Ky[key].DupKeys = (*s.get () != ' ');
|
||||||
|
TCodearray & c = expr.code ();
|
||||||
|
c.begin ();
|
||||||
|
int n = 0;
|
||||||
|
while (!c.end ())
|
||||||
{
|
{
|
||||||
_rec->Ky[key].DupKeys = (*s.get () != ' ');
|
TCode & inst = c.step ();
|
||||||
TCodearray & c = expr.code ();
|
TCodesym sym = inst.getsym ();
|
||||||
c.begin ();
|
|
||||||
int n = 0;
|
|
||||||
while (!c.end ())
|
|
||||||
{
|
|
||||||
TCode & inst = c.step ();
|
|
||||||
TCodesym sym = inst.getsym ();
|
|
||||||
|
|
||||||
if (sym == _variable)
|
if (sym == _variable)
|
||||||
{
|
{
|
||||||
const char *s = inst.string ();
|
const char *s = inst.string ();
|
||||||
|
|
||||||
for (int i = 0; i < _rec->NFields; i++)
|
for (int i = 0; i < _rec->NFields; i++)
|
||||||
if (strcmp (_rec->Fd[i].Name, s) == 0)
|
if (strcmp (_rec->Fd[i].Name, s) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_rec->Ky[key].FieldSeq[n] = i;
|
_rec->Ky[key].FieldSeq[n] = i;
|
||||||
_rec->Ky[key].FromCh[n] = INVFLD;
|
_rec->Ky[key].FromCh[n] = INVFLD;
|
||||||
_rec->Ky[key].FromCh[n] = INVFLD;
|
_rec->Ky[key].FromCh[n] = INVFLD;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
sym = inst.getsym ();
|
sym = inst.getsym ();
|
||||||
if (sym == _upper)
|
if (sym == _upper)
|
||||||
_rec->Ky[key].FieldSeq[n] += MaxFields;
|
_rec->Ky[key].FieldSeq[n] += MaxFields;
|
||||||
else if (sym == _number)
|
else if (sym == _number)
|
||||||
{
|
{
|
||||||
_rec->Ky[key].FromCh[n] = inst.number ().integer () - 1;
|
_rec->Ky[key].FromCh[n] = inst.number ().integer () - 1;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
_rec->Ky[key].ToCh[n] = _rec->Ky[key].FromCh[n] + inst.number ().integer () - 1;
|
_rec->Ky[key].ToCh[n] = _rec->Ky[key].FromCh[n] + inst.number ().integer () - 1;
|
||||||
inst = c.step ();
|
inst = c.step ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
c.backtrace ();
|
c.backtrace ();
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_rec->Ky[key].NkFields = n;
|
|
||||||
}
|
}
|
||||||
|
_rec->Ky[key].NkFields = n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec ::
|
void TTrec ::
|
||||||
print_on (ostream & out)
|
print_on (ostream & out)
|
||||||
const
|
const
|
||||||
|
|
||||||
{
|
{
|
||||||
out << num () << '\n';
|
out << num () << '\n';
|
||||||
const int nfields = fields ();
|
const int nfields = fields ();
|
||||||
TToken_string s (80);
|
TToken_string s (80);
|
||||||
|
|
||||||
out << nfields << '\n';
|
out << nfields << '\n';
|
||||||
for (int i = 0; i < nfields; i++)
|
for (int i = 0; i < nfields; i++)
|
||||||
{
|
{
|
||||||
s = fielddef (i);
|
s = fielddef (i);
|
||||||
out << s << '\n';
|
out << s << '\n';
|
||||||
}
|
}
|
||||||
const int nkeys = keys ();
|
const int nkeys = keys ();
|
||||||
|
|
||||||
out << nkeys << '\n';
|
out << nkeys << '\n';
|
||||||
for (i = 0; i < nkeys; i++)
|
for (i = 0; i < nkeys; i++)
|
||||||
{
|
{
|
||||||
s = keydef (i);
|
s = keydef (i);
|
||||||
out << s << '\n';
|
out << s << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrec ::
|
void TTrec ::
|
||||||
read_from (istream & in)
|
read_from (istream & in)
|
||||||
@ -474,19 +481,21 @@ read_from (istream & in)
|
|||||||
nfields = atoi (_files_tmp_string);
|
nfields = atoi (_files_tmp_string);
|
||||||
set_fields (nfields);
|
set_fields (nfields);
|
||||||
for (int i = 0; i < nfields; i++)
|
for (int i = 0; i < nfields; i++)
|
||||||
{
|
{
|
||||||
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
||||||
update_fielddef (i, _files_tmp_string);
|
update_fielddef (i, _files_tmp_string);
|
||||||
}
|
}
|
||||||
int nkeys;
|
int nkeys;
|
||||||
|
|
||||||
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
||||||
nkeys = atoi (_files_tmp_string);
|
nkeys = atoi (_files_tmp_string);
|
||||||
set_keys (nkeys);
|
set_keys (nkeys);
|
||||||
for (i = 0; i < nkeys; i++)
|
for (i = 0; i < nkeys; i++)
|
||||||
{
|
{
|
||||||
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
in.getline (_files_tmp_string, sizeof (_files_tmp_string), '\n');
|
||||||
update_keydef (i, _files_tmp_string);
|
update_keydef (i, _files_tmp_string);
|
||||||
}
|
}
|
||||||
rehash ();
|
rehash ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // FOXPRO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user