Patch level : 2.0 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento : Introdotti i fraction nelle librerie ed utilizzati per le conversioni Eliminata quasi dappertutto la __tmp_string git-svn-id: svn://10.65.10.50/trunk@11042 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
cf7a81a9bc
commit
9aab6a9dd5
@ -1,8 +1,32 @@
|
|||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fraction.h>
|
#include <fraction.h>
|
||||||
#include <utility.h>
|
|
||||||
|
static __int64 mcd(__int64 a, __int64 b)
|
||||||
|
{
|
||||||
|
if (a < 0)
|
||||||
|
a = -a;
|
||||||
|
if (b < 0)
|
||||||
|
b = -b;
|
||||||
|
|
||||||
|
__int64 r;
|
||||||
|
while (b > 0)
|
||||||
|
{
|
||||||
|
r = a % b;
|
||||||
|
a = b;
|
||||||
|
b = r;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __int64 mcm(__int64 a, __int64 b)
|
||||||
|
{
|
||||||
|
if (a < 0)
|
||||||
|
a = -a;
|
||||||
|
if (b < 0)
|
||||||
|
b = -b;
|
||||||
|
return ((a * b) / mcd(a, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void fraction::simplify()
|
void fraction::simplify()
|
||||||
{
|
{
|
||||||
@ -22,9 +46,10 @@ void fraction::simplify()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Crea una frazione a partire da una stringa avente la VIRGOLA come separatore dei decimali!
|
||||||
void fraction::build_fraction (const char *s)
|
void fraction::build_fraction (const char *s)
|
||||||
{
|
{
|
||||||
TString n = get_tmp_string(80); n = s;
|
TString80 n = s;
|
||||||
|
|
||||||
_num = 0;
|
_num = 0;
|
||||||
_den = 1;
|
_den = 1;
|
||||||
@ -43,7 +68,7 @@ void fraction::build_fraction (const char *s)
|
|||||||
|
|
||||||
if (psls > 0)
|
if (psls > 0)
|
||||||
{
|
{
|
||||||
TString80 num(n.left(psls));
|
TString80 num = n.left(psls);
|
||||||
fraction a(num);
|
fraction a(num);
|
||||||
num = n.mid(psls + 1);
|
num = n.mid(psls + 1);
|
||||||
fraction b(num);
|
fraction b(num);
|
||||||
@ -124,25 +149,34 @@ void fraction::build_fraction (const char *s)
|
|||||||
simplify();
|
simplify();
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction::fraction ()
|
fraction::fraction()
|
||||||
{
|
{
|
||||||
_num = 0;
|
_num = 0;
|
||||||
_den = 1;
|
_den = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction::fraction(const fraction & b)
|
fraction::fraction(const fraction& b)
|
||||||
{
|
{
|
||||||
_num = b._num;
|
_num = b._num;
|
||||||
_den = b._den;
|
_den = b._den;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fraction::fraction(const real& num, const real& den)
|
||||||
|
{
|
||||||
|
if (den == UNO)
|
||||||
|
build_fraction(num.stringa());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
real n = num; n /= den;
|
||||||
|
build_fraction(n.stringa());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int fraction::sign() const
|
int fraction::sign() const
|
||||||
{
|
{
|
||||||
if ( _num == 0 || _den == 0)
|
if ( _num == 0 || _den == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if ( _num < 0)
|
return _num < 0 ? (_den < 0 ? +1 : -1) : (_den < 0 ? -1 : +1);
|
||||||
return _den < 0 ? 1 : -1;
|
|
||||||
return _den < 0 ? -1 : 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction& fraction::operator =(const fraction & b)
|
fraction& fraction::operator =(const fraction & b)
|
||||||
@ -154,7 +188,7 @@ fraction& fraction::operator =(const fraction & b)
|
|||||||
|
|
||||||
fraction& fraction::operator += (const fraction & b)
|
fraction& fraction::operator += (const fraction & b)
|
||||||
{
|
{
|
||||||
__int64 m = mcm(_den, b._den);
|
const __int64 m = mcm(_den, b._den);
|
||||||
|
|
||||||
_num = _num * ( m / _den) + b._num * ( m / b._den);
|
_num = _num * ( m / _den) + b._num * ( m / b._den);
|
||||||
_den = m;
|
_den = m;
|
||||||
@ -191,7 +225,6 @@ fraction& fraction::operator /= (const fraction & b)
|
|||||||
fraction fraction::operator - () const
|
fraction fraction::operator - () const
|
||||||
{
|
{
|
||||||
fraction b(*this);
|
fraction b(*this);
|
||||||
|
|
||||||
b._num = -b._num;
|
b._num = -b._num;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@ -203,13 +236,14 @@ TObject* fraction::dup () const
|
|||||||
return new fraction(*this);
|
return new fraction(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction::operator real () const
|
fraction::operator real() const
|
||||||
{
|
{
|
||||||
real n, d;
|
real n, d;
|
||||||
n.set_int64(_num);
|
n.set_int64(_num);
|
||||||
d.set_int64(_den);
|
d.set_int64(_den);
|
||||||
|
|
||||||
return n / d;
|
real q = n; q /= d;
|
||||||
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
#ifndef __FRACTION_H
|
#ifndef __FRACTION_H
|
||||||
#define __FRACTION_H
|
#define __FRACTION_H
|
||||||
|
|
||||||
#ifndef __STRINGS_H
|
|
||||||
#include <strings.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __REAL_H
|
#ifndef __REAL_H
|
||||||
#include <real.h>
|
#include <real.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __IOSTREAM_H
|
|
||||||
#include <iostream.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
// @class fraction (per GREENLEAF) | Classe per la gestione dei numeri frazionari
|
// @class fraction (per GREENLEAF) | Classe per la gestione dei numeri frazionari
|
||||||
@ -21,7 +13,7 @@
|
|||||||
|
|
||||||
class fraction : public TObject
|
class fraction : public TObject
|
||||||
|
|
||||||
// @author:(INTERNAL) Guido
|
// @author:(INTERNAL) Alex
|
||||||
{
|
{
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
// @cmember:(INTERNAL) Numero fractione
|
// @cmember:(INTERNAL) Numero fractione
|
||||||
@ -38,7 +30,9 @@ protected:
|
|||||||
virtual TObject* dup() const;
|
virtual TObject* dup() const;
|
||||||
// @cmember assegna il numero frazionario (vedi classe <c TObject>)
|
// @cmember assegna il numero frazionario (vedi classe <c TObject>)
|
||||||
void simplify();
|
void simplify();
|
||||||
void build_fraction(const char * s);
|
|
||||||
|
// @cmember Crea una frazione a partire da una stringa avente la VIRGOLA come separatore dei decimali!
|
||||||
|
void build_fraction(const char* stringa);
|
||||||
|
|
||||||
// @access Public Member
|
// @access Public Member
|
||||||
public:
|
public:
|
||||||
@ -46,11 +40,13 @@ public:
|
|||||||
bool is_zero() const { return _num == 0;}
|
bool is_zero() const { return _num == 0;}
|
||||||
// @cmember Ritorna il segno del fraction
|
// @cmember Ritorna il segno del fraction
|
||||||
int sign() const ;
|
int sign() const ;
|
||||||
// @cmember Trasforma il fractione in intero (operator int era troppo pericoloso)
|
// @cmember Trasforma il fraction in intero (operator int era troppo pericoloso)
|
||||||
__int64 integer() const { return _num / _den;}
|
__int64 integer() const { return _num / _den;}
|
||||||
|
|
||||||
// @cmember Assegna una frazione
|
// @cmember Assegna una frazione
|
||||||
fraction& operator =(const fraction& b);
|
fraction& operator =(const fraction& b);
|
||||||
|
// @cmember Assegna una frazione
|
||||||
|
fraction& operator =(const real& b) { build_fraction(b.stringa()); return *this; }
|
||||||
// @cmember Aggiunge ad un frazione il valore passato
|
// @cmember Aggiunge ad un frazione il valore passato
|
||||||
fraction& operator +=(const fraction& b);
|
fraction& operator +=(const fraction& b);
|
||||||
// @cmember Sottrae ad un frazione il valore passato
|
// @cmember Sottrae ad un frazione il valore passato
|
||||||
@ -64,21 +60,20 @@ public:
|
|||||||
// @cmember Ritorna il risultato della differenza tra due frazioni
|
// @cmember Ritorna il risultato della differenza tra due frazioni
|
||||||
fraction operator -() const;
|
fraction operator -() const;
|
||||||
|
|
||||||
// @cmember converte la frazione in reale
|
// @cmember Trasforma il fraction in real
|
||||||
operator real() const;
|
operator real() const;
|
||||||
|
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
fraction();
|
fraction();
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
fraction(const real & b) { build_fraction(b.stringa()); }
|
fraction(const real &num, const real& den);
|
||||||
fraction(__int64 num, __int64 den = 1) : _num(num), _den(den) { simplify();}
|
fraction(__int64 num, __int64 den = 1) : _num(num), _den(den) { simplify(); }
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
fraction(const fraction& b) ;
|
fraction(const fraction& b) ;
|
||||||
// @cmember Costruttore
|
// @cmember Costruttore
|
||||||
fraction(const char* s) { build_fraction(s); }
|
fraction(const char* stringa) { build_fraction(stringa); }
|
||||||
// @cmember Distruttore
|
// @cmember Distruttore
|
||||||
virtual ~fraction()
|
virtual ~fraction() { }
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -86,46 +81,51 @@ public:
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
fraction operator +(const fraction& a, const fraction& b) ;
|
fraction operator +(const fraction& a, const fraction& b) ;
|
||||||
|
fraction operator -(const fraction& a, const fraction& b) ;
|
||||||
|
fraction operator *(const fraction& a, const fraction& b) ;
|
||||||
|
fraction operator /(const fraction& a, const fraction& b) ;
|
||||||
|
|
||||||
|
bool operator <(const fraction& a, const fraction& b) ;
|
||||||
|
bool operator >(const fraction& a, const fraction& b) ;
|
||||||
|
bool operator <=(const fraction& a, const fraction& b) ;
|
||||||
|
bool operator >=(const fraction& a, const fraction& b) ;
|
||||||
|
bool operator ==(const fraction& a, const fraction& b) ;
|
||||||
|
bool operator !=(const fraction& a, const fraction& b) ;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Valanga apparentemente inutile: aggiungere solo cio' che serve veramente!
|
||||||
inline fraction operator +(const real& a, const fraction& b) { return ::operator +((fraction)a, b);}
|
inline fraction operator +(const real& a, const fraction& b) { return ::operator +((fraction)a, b);}
|
||||||
inline fraction operator +(const fraction& a, const real& b) { return ::operator +(b, a);}
|
inline fraction operator +(const fraction& a, const real& b) { return ::operator +(b, a);}
|
||||||
inline fraction operator +(const fraction& a, __int64 b) { return ::operator +(a, (fraction)b);}
|
inline fraction operator +(const fraction& a, __int64 b) { return ::operator +(a, (fraction)b);}
|
||||||
inline fraction operator +(__int64 a, const fraction& b) { return ::operator +(b, a);}
|
inline fraction operator +(__int64 a, const fraction& b) { return ::operator +(b, a);}
|
||||||
fraction operator -(const fraction& a, const fraction& b) ;
|
|
||||||
inline fraction operator -(const real& a, const fraction& b) { return ::operator -((fraction)a, b);}
|
inline fraction operator -(const real& a, const fraction& b) { return ::operator -((fraction)a, b);}
|
||||||
inline fraction operator -(const fraction& a, const real& b) { return ::operator -(a, (fraction)b);}
|
inline fraction operator -(const fraction& a, const real& b) { return ::operator -(a, (fraction)b);}
|
||||||
inline fraction operator -(const fraction& a, __int64 b) { return ::operator -(a, (fraction)b);}
|
inline fraction operator -(const fraction& a, __int64 b) { return ::operator -(a, (fraction)b);}
|
||||||
inline fraction operator -(__int64 a, const fraction& b) { return ::operator -((fraction)a, b);}
|
inline fraction operator -(__int64 a, const fraction& b) { return ::operator -((fraction)a, b);}
|
||||||
fraction operator *(const fraction& a, const fraction& b) ;
|
|
||||||
inline fraction operator *(const real& a, const fraction& b) { return ::operator *((fraction)a, b);}
|
inline fraction operator *(const real& a, const fraction& b) { return ::operator *((fraction)a, b);}
|
||||||
inline fraction operator *(const fraction& a, const real& b) { return ::operator *(b, a);}
|
inline fraction operator *(const fraction& a, const real& b) { return ::operator *(b, a);}
|
||||||
fraction operator *(const fraction& a, __int64 b);
|
fraction operator *(const fraction& a, __int64 b);
|
||||||
inline fraction operator *(__int64 a, const fraction& b) { return ::operator *(b, a);}
|
inline fraction operator *(__int64 a, const fraction& b) { return ::operator *(b, a);}
|
||||||
fraction operator /(const fraction& a, const fraction& b) ;
|
|
||||||
inline fraction operator /(const real& a, const fraction& b) { return ::operator /((fraction)a, b);}
|
inline fraction operator /(const real& a, const fraction& b) { return ::operator /((fraction)a, b);}
|
||||||
inline fraction operator /(const fraction& a, const real& b) { return ::operator /(a, (fraction)b);}
|
inline fraction operator /(const fraction& a, const real& b) { return ::operator /(a, (fraction)b);}
|
||||||
fraction operator /(const fraction& a, __int64 b);
|
fraction operator /(const fraction& a, __int64 b);
|
||||||
fraction operator /(__int64 a, const fraction& b);
|
fraction operator /(__int64 a, const fraction& b);
|
||||||
|
|
||||||
bool operator <(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator <(const real& a, const fraction& b) { return ::operator < (a, (real)b);}
|
inline bool operator <(const real& a, const fraction& b) { return ::operator < (a, (real)b);}
|
||||||
inline bool operator <(const fraction& a, const real& b) { return ::operator <((real) a, b);}
|
inline bool operator <(const fraction& a, const real& b) { return ::operator <((real) a, b);}
|
||||||
bool operator >(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator >(const real& a, const fraction& b) { return ::operator > (a, (real)b);};
|
inline bool operator >(const real& a, const fraction& b) { return ::operator > (a, (real)b);};
|
||||||
inline bool operator >(const fraction& a, const real& b) { return ::operator >((real) a, b);}
|
inline bool operator >(const fraction& a, const real& b) { return ::operator >((real) a, b);}
|
||||||
bool operator <=(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator <=(const real& a, const fraction& b) { return ::operator <= (a, (real)b);}
|
inline bool operator <=(const real& a, const fraction& b) { return ::operator <= (a, (real)b);}
|
||||||
inline bool operator <=(const fraction& a, const real& b) { return operator <=((real) a, b);}
|
inline bool operator <=(const fraction& a, const real& b) { return operator <=((real) a, b);}
|
||||||
bool operator >=(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator >=(const real& a, const fraction& b) { return operator >=(a, (real) b);}
|
inline bool operator >=(const real& a, const fraction& b) { return operator >=(a, (real) b);}
|
||||||
inline bool operator >=(const fraction& a, const real& b) { return operator >=((real) a, b);}
|
inline bool operator >=(const fraction& a, const real& b) { return operator >=((real) a, b);}
|
||||||
bool operator ==(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator ==(const real& a, const fraction& b) { return operator ==(a, (real) b);}
|
inline bool operator ==(const real& a, const fraction& b) { return operator ==(a, (real) b);}
|
||||||
inline bool operator ==(const fraction& a, const real& b) { return operator ==((real) a, b);}
|
inline bool operator ==(const fraction& a, const real& b) { return operator ==((real) a, b);}
|
||||||
bool operator !=(const fraction& a, const fraction& b) ;
|
|
||||||
inline bool operator !=(const real& a, const fraction& b) { return operator !=(a, (real) b);}
|
inline bool operator !=(const real& a, const fraction& b) { return operator !=(a, (real) b);}
|
||||||
inline bool operator !=(const fraction& a, const real& b) { return operator !=((real) a, b);}
|
inline bool operator !=(const fraction& a, const real& b) { return operator !=((real) a, b);}
|
||||||
|
|
||||||
real operator %(const real& a, const real& b) ;
|
#endif
|
||||||
|
|
||||||
void swap(fraction& a, fraction& b) ;
|
void swap(fraction& a, fraction& b) ;
|
||||||
const fraction& fnc_min(const fraction& a, const fraction& b);
|
const fraction& fnc_min(const fraction& a, const fraction& b);
|
||||||
const fraction& fnc_max(const fraction& a, const fraction& b);
|
const fraction& fnc_max(const fraction& a, const fraction& b);
|
||||||
|
@ -2854,8 +2854,9 @@ TObject* TRectype::dup() const
|
|||||||
|
|
||||||
const char* TRectype::build_key(int num) const
|
const char* TRectype::build_key(int num) const
|
||||||
{
|
{
|
||||||
__build_key(rec_des(), num, string(), __tmp_string, TRUE);
|
TString& tmp = get_tmp_string(128);
|
||||||
return __tmp_string;
|
__build_key(rec_des(), num, string(), tmp.get_buffer(), TRUE);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TRectype::last_key_field(int key) const
|
const char* TRectype::last_key_field(int key) const
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define INFO_SIZE (sizeof(long)+sizeof(long))
|
#define INFO_SIZE (sizeof(long)+sizeof(long))
|
||||||
|
|
||||||
// block size used in writes
|
// block size used in writes
|
||||||
// must not exceed sizeof(__tmp_string)
|
|
||||||
#define BLOCK_SIZE (1024)
|
#define BLOCK_SIZE (1024)
|
||||||
// max allowed size for locking is 100k
|
// max allowed size for locking is 100k
|
||||||
#define MAX_SIZE (100000l)
|
#define MAX_SIZE (100000l)
|
||||||
|
@ -1087,7 +1087,8 @@ const char* TPrefix::description(
|
|||||||
// <nl>Passando il nome di una tabella in <p cod> si ottiene la stessa cosa della
|
// <nl>Passando il nome di una tabella in <p cod> si ottiene la stessa cosa della
|
||||||
// funzione <mf TDir::Tab_des>, ma viene cercato la descrizione nel titolo della maschera.
|
// funzione <mf TDir::Tab_des>, ma viene cercato la descrizione nel titolo della maschera.
|
||||||
{
|
{
|
||||||
TFilename n(cod);
|
TString& n = get_tmp_string();
|
||||||
|
n = cod;
|
||||||
|
|
||||||
if (n[0] == '%')
|
if (n[0] == '%')
|
||||||
n.ltrim(1);
|
n.ltrim(1);
|
||||||
@ -1108,7 +1109,7 @@ const char* TPrefix::description(
|
|||||||
else n.cut(0);
|
else n.cut(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return strcpy(__tmp_string, n);
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TPrefix::description(int cod) const
|
const char* TPrefix::description(int cod) const
|
||||||
@ -1134,7 +1135,7 @@ const TFirm& TPrefix::firm()
|
|||||||
const char* firm2dir(
|
const char* firm2dir(
|
||||||
long codditta) // @parm Codice ditta da convertire
|
long codditta) // @parm Codice ditta da convertire
|
||||||
{
|
{
|
||||||
TString16 firm;
|
TString8 firm;
|
||||||
switch (codditta)
|
switch (codditta)
|
||||||
{
|
{
|
||||||
case -2: // Dati generali campione
|
case -2: // Dati generali campione
|
||||||
@ -1145,8 +1146,10 @@ const char* firm2dir(
|
|||||||
default: // Dati ditta
|
default: // Dati ditta
|
||||||
firm.format("%05lda", codditta); break;
|
firm.format("%05lda", codditta); break;
|
||||||
}
|
}
|
||||||
_makepath(__tmp_string, NULL, __ptprf, firm, NULL);
|
|
||||||
return __tmp_string;
|
TString& path = get_tmp_string(256);
|
||||||
|
xvt_fsys_build_pathname(path.get_buffer(), NULL, __ptprf, firm, NULL, NULL);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
int safely_close_closeable_isamfiles()
|
int safely_close_closeable_isamfiles()
|
||||||
|
@ -504,10 +504,12 @@ void TPrint_application::set_header (
|
|||||||
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
...) // @parmvar Uno o piu' parametri corrispondenti ai codici in <p fmt>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
TString256 tmp;
|
||||||
|
|
||||||
CHECK (r >= 1, "Header rows start at 1");
|
CHECK (r >= 1, "Header rows start at 1");
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start (vl, fmt);
|
va_start (vl, fmt);
|
||||||
vsprintf (__tmp_string, fmt, vl);
|
vsprintf (tmp.get_buffer(), fmt, vl);
|
||||||
va_end (vl);
|
va_end (vl);
|
||||||
|
|
||||||
TPrintrow *pp = (TPrintrow *)_header.objptr(r - 1);
|
TPrintrow *pp = (TPrintrow *)_header.objptr(r - 1);
|
||||||
@ -516,7 +518,7 @@ void TPrint_application::set_header (
|
|||||||
pp = new TPrintrow;
|
pp = new TPrintrow;
|
||||||
_header.add (pp, r - 1);
|
_header.add (pp, r - 1);
|
||||||
}
|
}
|
||||||
pp->put (__tmp_string);
|
pp->put (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
@ -529,9 +531,10 @@ void TPrint_application::set_footer (
|
|||||||
|
|
||||||
{
|
{
|
||||||
CHECK (r >= 1, "Footer rows start at 1");
|
CHECK (r >= 1, "Footer rows start at 1");
|
||||||
|
TString256 tmp;
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start (vl, fmt);
|
va_start (vl, fmt);
|
||||||
vsprintf (__tmp_string, fmt, vl);
|
vsprintf (tmp.get_buffer(), fmt, vl);
|
||||||
va_end (vl);
|
va_end (vl);
|
||||||
TPrintrow *pp = (TPrintrow *) _footer.objptr (r - 1);
|
TPrintrow *pp = (TPrintrow *) _footer.objptr (r - 1);
|
||||||
if (pp == NULL)
|
if (pp == NULL)
|
||||||
@ -539,7 +542,7 @@ void TPrint_application::set_footer (
|
|||||||
pp = new TPrintrow;
|
pp = new TPrintrow;
|
||||||
_footer.add (pp, r - 1);
|
_footer.add (pp, r - 1);
|
||||||
}
|
}
|
||||||
pp->put (__tmp_string);
|
pp->put (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrint_application::reset_header ()
|
void TPrint_application::reset_header ()
|
||||||
@ -960,12 +963,10 @@ void TPrint_application::set_row (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef __LONGDOUBLE__
|
#ifdef __LONGDOUBLE__
|
||||||
sprintf (__tmp_string, formato, (long double)rrr);
|
sprintf (q.get_buffer(), formato, (long double)rrr);
|
||||||
#else
|
#else
|
||||||
char *fff = (char*)(const char *)formato;
|
dsprintf (q.get_buffer(), (char*)(const char*)formato, rrr.ptr());
|
||||||
dsprintf (__tmp_string, fff, rrr.ptr());
|
|
||||||
#endif
|
#endif
|
||||||
q = __tmp_string;
|
|
||||||
}
|
}
|
||||||
if (rrr.is_zero () && !_print_zero)
|
if (rrr.is_zero () && !_print_zero)
|
||||||
q.fill (' ', q.len());
|
q.fill (' ', q.len());
|
||||||
@ -1475,11 +1476,10 @@ bool TPrint_application::print_one (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef __LONGDOUBLE__
|
#ifdef __LONGDOUBLE__
|
||||||
sprintf(__tmp_string, fff, (long double)rrr);
|
sprintf(ps.get_buffer(), fff, (long double)rrr);
|
||||||
#else
|
#else
|
||||||
dsprintf(__tmp_string, (char*)fff, rrr.ptr());
|
dsprintf(ps.get_buffer(), (char*)fff, rrr.ptr());
|
||||||
#endif
|
#endif
|
||||||
ps = __tmp_string;
|
|
||||||
}
|
}
|
||||||
if (rrr.is_zero () && !_print_zero)
|
if (rrr.is_zero () && !_print_zero)
|
||||||
ps.fill (' ', ps.len());
|
ps.fill (' ', ps.len());
|
||||||
|
@ -615,6 +615,8 @@ const char* TPrintrow::row_codified() const
|
|||||||
int last_color = -1;
|
int last_color = -1;
|
||||||
int k = 0, i = 0, len = 0;
|
int k = 0, i = 0, len = 0;
|
||||||
|
|
||||||
|
char* tmp = get_tmp_string(256).get_buffer();
|
||||||
|
|
||||||
// Calcolo lunghezza stringa
|
// Calcolo lunghezza stringa
|
||||||
for (i = _row.size()-1; i >= 0; i--)
|
for (i = _row.size()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -629,54 +631,54 @@ const char* TPrintrow::row_codified() const
|
|||||||
{
|
{
|
||||||
if (_tab[i])
|
if (_tab[i])
|
||||||
{
|
{
|
||||||
__tmp_string[k++] = '@';
|
tmp[k++] = '@';
|
||||||
__tmp_string[k++] = 't';
|
tmp[k++] = 't';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_attr[i] != last_attr)
|
if (_attr[i] != last_attr)
|
||||||
{
|
{
|
||||||
__tmp_string[k++] = '@';
|
tmp[k++] = '@';
|
||||||
switch (_attr[i])
|
switch (_attr[i])
|
||||||
{
|
{
|
||||||
case normalstyle:
|
case normalstyle:
|
||||||
__tmp_string[k++] = 'r';
|
tmp[k++] = 'r';
|
||||||
break;
|
break;
|
||||||
case boldstyle:
|
case boldstyle:
|
||||||
__tmp_string[k++] = 'b';
|
tmp[k++] = 'b';
|
||||||
break;
|
break;
|
||||||
case italicstyle:
|
case italicstyle:
|
||||||
__tmp_string[k++] = 'i';
|
tmp[k++] = 'i';
|
||||||
break;
|
break;
|
||||||
case underlinedstyle:
|
case underlinedstyle:
|
||||||
__tmp_string[k++] = 'u';
|
tmp[k++] = 'u';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last_attr = _attr[i];
|
last_attr = _attr[i];
|
||||||
}
|
}
|
||||||
if (_cols[i] != last_color)
|
if (_cols[i] != last_color)
|
||||||
{
|
{
|
||||||
__tmp_string[k++] = '$';
|
tmp[k++] = '$';
|
||||||
__tmp_string[k++] = '[';
|
tmp[k++] = '[';
|
||||||
__tmp_string[k++] = (char) (_cols[i] & 0x00ff);
|
tmp[k++] = (char) (_cols[i] & 0x00ff);
|
||||||
__tmp_string[k++] = ',';
|
tmp[k++] = ',';
|
||||||
__tmp_string[k++] = (char) (_cols[i] >> 8);
|
tmp[k++] = (char) (_cols[i] >> 8);
|
||||||
__tmp_string[k++] = ']';
|
tmp[k++] = ']';
|
||||||
last_color = _cols[i];
|
last_color = _cols[i];
|
||||||
}
|
}
|
||||||
if (_row[i] == '@' && strchr("<#>", _row[i+1]) == NULL)
|
if (_row[i] == '@' && strchr("<#>", _row[i+1]) == NULL)
|
||||||
__tmp_string[k++] = '@'; // Escape for @
|
tmp[k++] = '@'; // Escape for @
|
||||||
__tmp_string[k++] = _row[i];
|
tmp[k++] = _row[i];
|
||||||
}
|
}
|
||||||
__tmp_string[k] = '\0';
|
tmp[k] = '\0';
|
||||||
|
|
||||||
if (_images)
|
if (_images)
|
||||||
{
|
{
|
||||||
strcat(__tmp_string, "$[w,w]"); // Bianco su bianco!
|
strcat(tmp, "$[w,w]"); // Bianco su bianco!
|
||||||
FOR_EACH_TOKEN((*_images), tok)
|
FOR_EACH_TOKEN((*_images), tok)
|
||||||
strcat(__tmp_string, tok);
|
strcat(tmp, tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
return __tmp_string;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintrow& TPrintrow::put(const char *str, int position, int len)
|
TPrintrow& TPrintrow::put(const char *str, int position, int len)
|
||||||
@ -1126,7 +1128,7 @@ void TPrinter::save_configuration()
|
|||||||
TConfig prini(_config == "Printer" ? CONFIG_USER : CONFIG_STAMPE, _config);
|
TConfig prini(_config == "Printer" ? CONFIG_USER : CONFIG_STAMPE, _config);
|
||||||
|
|
||||||
prini.set("Type", _printertype); // Tipo stampante
|
prini.set("Type", _printertype); // Tipo stampante
|
||||||
prini.set("Name", _prname); // Numero stampante corrente
|
prini.set("Name", _prname); // Nome stampante corrente
|
||||||
prini.set("File", _printerfile); // File di stampa
|
prini.set("File", _printerfile); // File di stampa
|
||||||
prini.set("Font", _fontname); // Nome del font
|
prini.set("Font", _fontname); // Nome del font
|
||||||
prini.set("Size", _ch_size); // Dimensione del font
|
prini.set("Size", _ch_size); // Dimensione del font
|
||||||
|
@ -3,15 +3,17 @@
|
|||||||
|
|
||||||
#include <real.h>
|
#include <real.h>
|
||||||
|
|
||||||
const real ZERO (0.0);
|
const real ZERO(0.0);
|
||||||
|
const real UNO(1.0);
|
||||||
|
const real CENTO(100.0);
|
||||||
|
|
||||||
#ifdef __LONGDOUBLE__
|
#ifdef __LONGDOUBLE__
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN32
|
|
||||||
|
|
||||||
inline long double _atold(const char* str)
|
inline long double _atold(const char* str)
|
||||||
{
|
{
|
||||||
long double num = 0.0;
|
long double num = 0.0;
|
||||||
|
@ -320,6 +320,8 @@ real abs(const real& a) ;
|
|||||||
// TReal implementato coi maledetti DEC
|
// TReal implementato coi maledetti DEC
|
||||||
|
|
||||||
extern const real ZERO;
|
extern const real ZERO;
|
||||||
|
extern const real UNO;
|
||||||
|
extern const real CENTO;
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
|
@ -298,8 +298,9 @@ TObject* TString::dup() const
|
|||||||
|
|
||||||
void TString::read_from(istream& in)
|
void TString::read_from(istream& in)
|
||||||
{
|
{
|
||||||
in >> __tmp_string;
|
char tmp[256];
|
||||||
set(__tmp_string);
|
in >> tmp;
|
||||||
|
set(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,7 +245,9 @@ const char* cmd2name(
|
|||||||
app.cut(3);
|
app.cut(3);
|
||||||
app << c << "00";
|
app << c << "00";
|
||||||
|
|
||||||
return strcpy(__tmp_string, app);
|
TString& tmp = get_tmp_string();
|
||||||
|
tmp = app;
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -446,10 +448,11 @@ const char * encode(
|
|||||||
|
|
||||||
// @xref <f decode>
|
// @xref <f decode>
|
||||||
{
|
{
|
||||||
|
char* tmp = get_tmp_string(50).get_buffer();
|
||||||
for (int i = 0; data[i]; i++)
|
for (int i = 0; data[i]; i++)
|
||||||
__tmp_string[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]);
|
tmp[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]);
|
||||||
__tmp_string[i] = '\0';
|
tmp[i] = '\0';
|
||||||
return __tmp_string;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
@ -462,38 +465,10 @@ const char * decode(
|
|||||||
|
|
||||||
// @xref <f encode>
|
// @xref <f encode>
|
||||||
{
|
{
|
||||||
|
char* tmp = get_tmp_string(50).get_buffer();
|
||||||
for (int i = 0; data[i]; i++)
|
for (int i = 0; data[i]; i++)
|
||||||
__tmp_string[i] = data[i] - (i < 8 ? encryption_key[i] : __tmp_string[i - 8]);
|
tmp[i] = data[i] - (i < 8 ? encryption_key[i] : tmp[i - 8]);
|
||||||
__tmp_string[i] = '\0';
|
tmp[i] = '\0';
|
||||||
return __tmp_string;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 mcd(__int64 a, __int64 b)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (a < 0)
|
|
||||||
a = -a;
|
|
||||||
if (b < 0)
|
|
||||||
b = -b;
|
|
||||||
|
|
||||||
__int64 r;
|
|
||||||
|
|
||||||
while (b > 0)
|
|
||||||
{
|
|
||||||
r = a % b;
|
|
||||||
a = b;
|
|
||||||
b = r;
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
__int64 mcm(__int64 a, __int64 b)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (a < 0)
|
|
||||||
a = -a;
|
|
||||||
if (b < 0)
|
|
||||||
b = -b;
|
|
||||||
|
|
||||||
return ((a * b) / mcd(a, b));
|
|
||||||
}
|
|
||||||
|
@ -41,9 +41,6 @@ const char* unesc(const char* str); // Trasforma i caratteri '\n' nella sequenza
|
|||||||
#define ODD(x) (x & 1)
|
#define ODD(x) (x & 1)
|
||||||
#define EVEN(x) !(x & 1)
|
#define EVEN(x) !(x & 1)
|
||||||
|
|
||||||
__int64 mcd(__int64 a, __int64 b);
|
|
||||||
__int64 mcm(__int64 a, __int64 b);
|
|
||||||
|
|
||||||
#ifdef __UTILITY_CPP
|
#ifdef __UTILITY_CPP
|
||||||
char __tmp_string[1024];
|
char __tmp_string[1024];
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user