Patch level : 10.0

Files correlati     : ve1 ba8
Ricompilazione Demo : [ ]
Commento            :
Corretto ordinamento date nelle espressioni BY delle query.
Portato limite di lunghezza dei nomi dei file temporanei da 42 a 260 caratteri.


git-svn-id: svn://10.65.10.50/trunk@19764 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-12-14 14:09:35 +00:00
parent edebc36b52
commit d77c676749
5 changed files with 25 additions and 25 deletions

View File

@ -35,14 +35,14 @@ static char *init_sptr;
static unsigned rcds_seq;
/* @(:) 2.3.00.112 */
static FILE *fp1, *fp2;
static char fdname [42];
static char f2name [42];
static char fdname [_MAX_PATH];
static char f2name [_MAX_PATH];
//static int sortcomp(char **, char **);
static int sortcomp(const void*, const void*);
static char *appr_mem(unsigned *);
/* @(!) 2.3.00.112 */
static FILE *wopen(char *);
static FILE *wopen(char *, int);
/* @(:) 2.3.00.112 */
static void dumpbuff(void);
static void merge(void);
@ -90,9 +90,7 @@ int init_sort(struct s_prm *prms)
@(FN)
*/
void sort(s_rcd)
char *s_rcd; /* buffer contenente il record da ordinare */
void sort(const char* s_rcd) /* buffer contenente il record da ordinare */
{
/* @(!) 2.3.00.112 */
if (inbf == nrcds) { /* if the sort buffer is full */
@ -159,9 +157,9 @@ static void prep_merge()
while (rcds_seq < 2) {
FILE *hd;
/* @(!) 2.3.00.112 */
char wname[42]; /* sort work name */
char wname[_MAX_PATH]; /* sort work name */
fp2 = wopen(f2name); /* open a sort work file */
fp2 = wopen(f2name, sizeof(wname)); /* open a sort work file */
/* @(:) 2.3.00.112 */
merge(); /* binary merge */
hd = fp1; /* swap fds */
@ -353,7 +351,7 @@ static void dumpbuff()
if (fp1 == NULL)
/* @(!) 2.3.00.112 */
fp1 = wopen(fdname);
fp1 = wopen(fdname, sizeof(fdname));
/* @(:) 2.3.00.112 */
sptr = (char **) init_sptr;
for (i = 0; i < inbf; i++) {
@ -382,17 +380,17 @@ static void dumpbuff()
@(FSV)
*/
static FILE *wopen(char* name) /* nome del file temporaneo */
static FILE *wopen(char* name, int size) /* nome del file temporaneo */
{
FILE* fp = NULL;
char* tmp = _tempnam(".", "srt");
if (tmp != NULL)
{
strcpy(name, tmp);
strncpy(name, tmp, size);
free(tmp);
}
else
tmpnam(name);
tmpnam_s(name, size);
fp = fopen(name, "wb+");
if (fp == NULL)
xvt_dm_post_fatal_exit("Can't open SORT file");

View File

@ -26,7 +26,7 @@ extern "C" {
/*----------------------- FUNZIONI VISIBILI PRIMA PARTE ---------------------*/
int init_sort(struct s_prm *); /* Initialize the sort */
void sort(char *); /* Pass records to Sort */
void sort(const char *); /* Pass records to Sort */
char *sort_op(void); /* Retrieve sorted records */
void sort_stats(void); /* Display sort statistics */

View File

@ -62,7 +62,7 @@ extern "C" {
void CPutPref(const char *);
char *CInsPref(char *, int);
int init_sort(struct s_prm *);
void sort(char *);
void sort(const char *);
char *sort_op(void);
void sort_stats(void);

View File

@ -1917,7 +1917,7 @@ TRecnotype TSorted_cursor::buildcursor(TRecnotype rp)
const TRectype& r = relation()->lfile(id).curr();
const int flen = f.len(r);
if (!id.empty())
if (id.full())
{
_sort_update = true;
const int file_id = relation()->name2ind(id);
@ -2024,22 +2024,24 @@ const char* TSorted_cursor::fill_sort_key(TString& k)
if (fld_type == _datefld || (f.is_subfield() && TDate::isdate(sf)))
{
const TDate d(sf);
sf = d.string(ANSI);
sf.format("%08ld", d.date2ansi());
fld_type = _datefld;
fld_len = 10;
fld_len = 8;
}
else
{
if (is_up)
sf.upper();
}
TString8 fmt;
if (fld_type == _alfafld || fld_type == _datefld)
fmt.format("%%-%ds", fld_len);
else
fmt.format("%%%ds", fld_len);
k << format(fmt, (const char*)sf);
switch (fld_type)
{
case _boolfld:
case _charfld:
case _alfafld: sf.left_just(fld_len); break;
case _datefld: break; // Gia' lungo 8!
default : sf.right_just(fld_len); break;
}
k << sf;
}
return k;
}

View File

@ -37,7 +37,7 @@ void TSort::sort(const char* record)
{
CHECK(record != NULL, "Bad record to sort");
::sort((char*)record);
::sort(record);
}