From d77c676749ad26c9716ce4c1fda6d5a492897d35 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 14 Dec 2009 14:09:35 +0000 Subject: [PATCH] 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 --- include/csort.c | 22 ++++++++++------------ include/csort.h | 2 +- include/extcdecl.h | 2 +- include/relation.cpp | 22 ++++++++++++---------- include/sort.cpp | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/csort.c b/include/csort.c index d0bb73521..b3563f71c 100755 --- a/include/csort.c +++ b/include/csort.c @@ -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"); diff --git a/include/csort.h b/include/csort.h index 85feb6e9e..47aae22c9 100755 --- a/include/csort.h +++ b/include/csort.h @@ -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 */ diff --git a/include/extcdecl.h b/include/extcdecl.h index ca5d51dca..d54002c27 100755 --- a/include/extcdecl.h +++ b/include/extcdecl.h @@ -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); diff --git a/include/relation.cpp b/include/relation.cpp index 6c0c68857..132308e16 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -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; } diff --git a/include/sort.cpp b/include/sort.cpp index e87bd9018..0e373c0af 100755 --- a/include/sort.cpp +++ b/include/sort.cpp @@ -37,7 +37,7 @@ void TSort::sort(const char* record) { CHECK(record != NULL, "Bad record to sort"); - ::sort((char*)record); + ::sort(record); }