summaryrefslogtreecommitdiff
path: root/storage/connect/value.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2017-05-23 19:35:50 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2017-05-23 19:35:50 +0200
commit3e36eb230b65d53acc8e02b00a024e72ed249425 (patch)
treebe89d99353fc70488a5b43707fac12b960f2f29b /storage/connect/value.cpp
parente8333389c89c946d3794ec9ea708d308318301a3 (diff)
downloadmariadb-git-3e36eb230b65d53acc8e02b00a024e72ed249425.tar.gz
Fix gcc compiler warnings reported by Sergei
modified: storage/connect/array.cpp modified: storage/connect/array.h modified: storage/connect/blkfil.cpp modified: storage/connect/blkfil.h modified: storage/connect/block.h modified: storage/connect/colblk.cpp modified: storage/connect/colblk.h modified: storage/connect/csort.h modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/filter.h modified: storage/connect/global.h modified: storage/connect/json.h modified: storage/connect/plgdbsem.h modified: storage/connect/plgdbutl.cpp modified: storage/connect/tabcol.cpp modified: storage/connect/tabcol.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabjson.cpp modified: storage/connect/table.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabsys.h modified: storage/connect/tabxml.h modified: storage/connect/value.cpp modified: storage/connect/value.h modified: storage/connect/xindex.cpp modified: storage/connect/xindex.h modified: storage/connect/xobject.cpp modified: storage/connect/xobject.h modified: storage/connect/xtable.h Set values as nullable when retrieving catalog info modified: storage/connect/jdbconn.cpp modified: storage/connect/mysql-test/connect/r/odbc_oracle.result modified: storage/connect/odbconn.cpp Change format of Jpath modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/mysql-test/connect/r/json.result modified: storage/connect/mysql-test/connect/r/json_udf.result modified: storage/connect/mysql-test/connect/r/json_udf_bin.result modified: storage/connect/mysql-test/connect/r/zip.result modified: storage/connect/mysql-test/connect/t/json.test modified: storage/connect/mysql-test/connect/t/json_udf.test modified: storage/connect/mysql-test/connect/t/json_udf_bin.test modified: storage/connect/mysql-test/connect/t/zip.test modified: storage/connect/tabjson.cpp modified: storage/connect/tabjson.h modified: storage/connect/tabmgo.cpp Change null representation from ??? to <null> modified: storage/connect/json.cpp Change the name of UDF that are equal to a native JSON function name modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h modified: storage/connect/mysql-test/connect/t/json_udf.inc modified: storage/connect/mysql-test/connect/t/json_udf2.inc Fix bug in making JSON project info modified: storage/connect/mongofam.cpp Fix COMPUTE when one argument is null modified: storage/connect/value.cpp Value is null only when nullable modified: storage/connect/value.h
Diffstat (limited to 'storage/connect/value.cpp')
-rw-r--r--storage/connect/value.cpp379
1 files changed, 140 insertions, 239 deletions
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index ced690e77c0..b488f7aa061 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -1,7 +1,7 @@
/************* Value C++ Functions Source Code File (.CPP) *************/
-/* Name: VALUE.CPP Version 2.6 */
+/* Name: VALUE.CPP Version 2.8 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
+/* (C) Copyright to the author Olivier BERTRAND 2001-2017 */
/* */
/* This file contains the VALUE and derived classes family functions. */
/* These classes contain values of different types. They are used so */
@@ -60,7 +60,7 @@
#define CheckType(V) if (Type != V->GetType()) { \
PGLOBAL& g = Global; \
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
- longjmp(g->jumper[g->jump_level], Type); }
+ throw Type;
#else
#define CheckType(V)
#endif
@@ -94,12 +94,12 @@ PSZ strlwr(PSZ s);
/* OUT minus: Set to true if the number is negative */
/* Returned val: The resulting number */
/***********************************************************************/
-ulonglong CharToNumber(char *p, int n, ulonglong maxval,
+ulonglong CharToNumber(const char *p, int n, ulonglong maxval,
bool un, bool *minus, bool *rc)
{
- char *p2;
- uchar c;
- ulonglong val;
+ const char *p2;
+ uchar c;
+ ulonglong val;
if (minus) *minus = false;
if (rc) *rc = false;
@@ -138,9 +138,9 @@ ulonglong CharToNumber(char *p, int n, ulonglong maxval,
/***********************************************************************/
/* GetTypeName: returns the PlugDB internal type name. */
/***********************************************************************/
-PSZ GetTypeName(int type)
+PCSZ GetTypeName(int type)
{
- PSZ name;
+ PCSZ name;
switch (type) {
case TYPE_STRING: name = "CHAR"; break;
@@ -184,9 +184,9 @@ int GetTypeSize(int type, int len)
/***********************************************************************/
/* GetFormatType: returns the FORMAT character(s) according to type. */
/***********************************************************************/
-char *GetFormatType(int type)
+const char *GetFormatType(int type)
{
- char *c = "X";
+ const char *c = "X";
switch (type) {
case TYPE_STRING: c = "C"; break;
@@ -370,7 +370,7 @@ PVAL AllocateValue(PGLOBAL g, void *value, short type, short prec)
/* Allocate a variable Value according to type, length and precision. */
/***********************************************************************/
PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
- bool uns, PSZ fmt)
+ bool uns, PCSZ fmt)
{
PVAL valp;
@@ -558,6 +558,38 @@ bool VALUE::Compute(PGLOBAL g, PVAL *, int, OPVAL)
return true;
} // end of Compute
+/***********************************************************************/
+/* Make file output of an object value. */
+/***********************************************************************/
+void VALUE::Printf(PGLOBAL g, FILE *f, uint n)
+{
+ char m[64], buf[64];
+
+ memset(m, ' ', n); /* Make margin string */
+ m[n] = '\0';
+
+ if (Null)
+ fprintf(f, "%s<null>\n", m);
+ else
+ fprintf(f, strcat(strcat(GetCharString(buf), "\n"), m));
+
+} /* end of Printf */
+
+/***********************************************************************/
+/* Make string output of an object value. */
+/***********************************************************************/
+void VALUE::Prints(PGLOBAL g, char *ps, uint z)
+{
+ char *p, buf[64];
+
+ if (Null)
+ p = strcpy(buf, "<null>");
+ else
+ p = GetCharString(buf);
+
+ strncpy(ps, p, z);
+} // end of Prints
+
/* -------------------------- Class TYPVAL ---------------------------- */
/***********************************************************************/
@@ -682,7 +714,7 @@ uchar TYPVAL<uchar>::GetTypedValue(PVAL valp)
/* TYPVAL SetValue: convert chars extracted from a line to TYPE value.*/
/***********************************************************************/
template <class TYPE>
-bool TYPVAL<TYPE>::SetValue_char(char *p, int n)
+bool TYPVAL<TYPE>::SetValue_char(const char *p, int n)
{
bool rc, minus;
ulonglong maxval = MaxVal();
@@ -704,7 +736,7 @@ bool TYPVAL<TYPE>::SetValue_char(char *p, int n)
} // end of SetValue
template <>
-bool TYPVAL<double>::SetValue_char(char *p, int n)
+bool TYPVAL<double>::SetValue_char(const char *p, int n)
{
if (p && n > 0) {
char buf[64];
@@ -732,7 +764,7 @@ bool TYPVAL<double>::SetValue_char(char *p, int n)
/* TYPVAL SetValue: fill a typed value from a string. */
/***********************************************************************/
template <class TYPE>
-void TYPVAL<TYPE>::SetValue_psz(PSZ s)
+void TYPVAL<TYPE>::SetValue_psz(PCSZ s)
{
if (s) {
SetValue_char(s, (int)strlen(s));
@@ -1019,12 +1051,12 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
if ((n2 > 0) && (n < n1)) {
// Overflow
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
- longjmp(g->jumper[g->jump_level], 138);
- } else if ((n2 < 0) && (n > n1)) {
+ throw 138;
+ } else if ((n2 < 0) && (n > n1)) {
// Underflow
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
- longjmp(g->jumper[g->jump_level], 138);
- } // endif's n2
+ throw 138;
+ } // endif's n2
return n;
} // end of SafeAdd
@@ -1047,12 +1079,12 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
if (n > MinMaxVal(true)) {
// Overflow
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
- longjmp(g->jumper[g->jump_level], 138);
- } else if (n < MinMaxVal(false)) {
+ throw 138;
+ } else if (n < MinMaxVal(false)) {
// Underflow
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
- longjmp(g->jumper[g->jump_level], 138);
- } // endif's n2
+ throw 138;
+ } // endif's n2
return (TYPE)n;
} // end of SafeMult
@@ -1170,7 +1202,7 @@ bool TYPVAL<TYPE>::Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op)
/* This function assumes that the format matches the value type. */
/***********************************************************************/
template <class TYPE>
-bool TYPVAL<TYPE>::FormatValue(PVAL vp, char *fmt)
+bool TYPVAL<TYPE>::FormatValue(PVAL vp, PCSZ fmt)
{
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Tval);
@@ -1192,37 +1224,6 @@ bool TYPVAL<TYPE>::SetConstFormat(PGLOBAL g, FORMAT& fmt)
return false;
} // end of SetConstFormat
-/***********************************************************************/
-/* Make file output of a typed object. */
-/***********************************************************************/
-template <class TYPE>
-void TYPVAL<TYPE>::Print(PGLOBAL g, FILE *f, uint n)
- {
- char m[64], buf[12];
-
- memset(m, ' ', n); /* Make margin string */
- m[n] = '\0';
-
- if (Null)
- fprintf(f, "%s<null>\n", m);
- else
- fprintf(f, strcat(strcat(strcpy(buf, "%s"), Fmt), "\n"), m, Tval);
-
- } /* end of Print */
-
-/***********************************************************************/
-/* Make string output of a int object. */
-/***********************************************************************/
-template <class TYPE>
-void TYPVAL<TYPE>::Print(PGLOBAL g, char *ps, uint z)
- {
- if (Null)
- strcpy(ps, "<null>");
- else
- sprintf(ps, Fmt, Tval);
-
- } /* end of Print */
-
/* -------------------------- Class STRING --------------------------- */
/***********************************************************************/
@@ -1361,25 +1362,25 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/
/* STRING SetValue: fill string with chars extracted from a line. */
/***********************************************************************/
-bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
+bool TYPVAL<PSZ>::SetValue_char(const char *cp, int n)
{
bool rc = false;
- if (!p || n == 0) {
+ if (!cp || n == 0) {
Reset();
Null = Nullable;
- } else if (p != Strp) {
- rc = n > Len;
+ } else if (cp != Strp) {
+ const char *p = cp + n - 1;
- if ((n = MY_MIN(n, Len))) {
- strncpy(Strp, p, n);
+ for (p; p >= cp; p--, n--)
+ if (*p && *p != ' ')
+ break;
-// for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
- for (p = Strp + n - 1; p >= Strp; p--)
- if (*p && *p != ' ')
- break;
+ rc = n > Len;
- *(++p) = '\0';
+ if ((n = MY_MIN(n, Len))) {
+ strncpy(Strp, cp, n);
+ Strp[n] = '\0';
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
@@ -1396,7 +1397,7 @@ bool TYPVAL<PSZ>::SetValue_char(char *p, int n)
/***********************************************************************/
/* STRING SetValue: fill string with another string. */
/***********************************************************************/
-void TYPVAL<PSZ>::SetValue_psz(PSZ s)
+void TYPVAL<PSZ>::SetValue_psz(PCSZ s)
{
if (!s) {
Reset();
@@ -1432,8 +1433,8 @@ void TYPVAL<PSZ>::SetValue(int n)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+ throw 138;
+ } else
SetValue_psz(buf);
Null = false;
@@ -1486,8 +1487,8 @@ void TYPVAL<PSZ>::SetValue(longlong n)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+ throw 138;
+ } else
SetValue_psz(buf);
Null = false;
@@ -1529,8 +1530,8 @@ void TYPVAL<PSZ>::SetValue(double f)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+ throw 138;
+ } else
SetValue_psz(buf);
Null = false;
@@ -1559,7 +1560,7 @@ void TYPVAL<PSZ>::SetValue(uchar c)
/***********************************************************************/
void TYPVAL<PSZ>::SetBinValue(void *p)
{
- SetValue_char((char *)p, Len);
+ SetValue_char((const char *)p, Len);
} // end of SetBinValue
/***********************************************************************/
@@ -1654,32 +1655,36 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
int i;
for (i = 0; i < np; i++)
- p[i] = vp[i]->GetCharString(val[i]);
-
- switch (op) {
- case OP_CNC:
- assert(np == 1 || np == 2);
-
- if (np == 2)
- SetValue_psz(p[0]);
-
- if ((i = Len - (signed)strlen(Strp)) > 0)
- strncat(Strp, p[np - 1], i);
-
- break;
- case OP_MIN:
- assert(np == 2);
- SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
- break;
- case OP_MAX:
- assert(np == 2);
- SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
- break;
- default:
-// sprintf(g->Message, MSG(BAD_EXP_OPER), op);
- strcpy(g->Message, "Function not supported");
- return true;
- } // endswitch op
+ p[i] = vp[i]->IsNull() ? NULL : vp[i]->GetCharString(val[i]);
+
+ if (p[i]) {
+ switch (op) {
+ case OP_CNC:
+ assert(np == 1 || np == 2);
+
+ if (np == 2)
+ SetValue_psz(p[0]);
+
+ if ((i = Len - (signed)strlen(Strp)) > 0)
+ strncat(Strp, p[np - 1], i);
+
+ break;
+ case OP_MIN:
+ assert(np == 2);
+ SetValue_psz((strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
+ break;
+ case OP_MAX:
+ assert(np == 2);
+ SetValue_psz((strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
+ break;
+ default:
+ // sprintf(g->Message, MSG(BAD_EXP_OPER), op);
+ strcpy(g->Message, "Function not supported");
+ return true;
+ } // endswitch op
+
+ Null = false;
+ } // endif p[i]
return false;
} // end of Compute
@@ -1689,7 +1694,7 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
/* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */
/***********************************************************************/
-bool TYPVAL<PSZ>::FormatValue(PVAL vp, char *fmt)
+bool TYPVAL<PSZ>::FormatValue(PVAL vp, PCSZ fmt)
{
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Strp);
@@ -1708,6 +1713,18 @@ bool TYPVAL<PSZ>::SetConstFormat(PGLOBAL, FORMAT& fmt)
return false;
} // end of SetConstFormat
+/***********************************************************************/
+/* Make string output of an object value. */
+/***********************************************************************/
+void TYPVAL<PSZ>::Prints(PGLOBAL g, char *ps, uint z)
+{
+ if (Null)
+ strncpy(ps, "null", z);
+ else
+ strcat(strncat(strncpy(ps, "\"", z), Strp, z-2), "\"");
+
+} // end of Prints
+
/* -------------------------- Class DECIMAL -------------------------- */
/***********************************************************************/
@@ -1797,102 +1814,6 @@ bool DECVAL::GetBinValue(void *buf, int buflen, bool go)
return false;
} // end of GetBinValue
-#if 0
-/***********************************************************************/
-/* DECIMAL SetValue: copy the value of another Value object. */
-/***********************************************************************/
-bool DECVAL::SetValue_pval(PVAL valp, bool chktype)
- {
- if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
- return true;
-
- char buf[64];
-
- if (!(Null = valp->IsNull() && Nullable))
- strncpy(Strp, valp->GetCharString(buf), Len);
- else
- Reset();
-
- return false;
- } // end of SetValue_pval
-
-/***********************************************************************/
-/* DECIMAL SetValue: fill string with chars extracted from a line. */
-/***********************************************************************/
-bool DECVAL::SetValue_char(char *p, int n)
- {
- bool rc;
-
- if (p && n > 0) {
- rc = n > Len;
-
- if ((n = MY_MIN(n, Len))) {
- strncpy(Strp, p, n);
-
-// for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
- for (p = Strp + n - 1; p >= Strp; p--)
- if (*p && *p != ' ')
- break;
-
- *(++p) = '\0';
-
- if (trace > 1)
- htrc(" Setting string to: '%s'\n", Strp);
-
- } else
- Reset();
-
- Null = false;
- } else {
- rc = false;
- Reset();
- Null = Nullable;
- } // endif p
-
- return rc;
- } // end of SetValue_char
-
-/***********************************************************************/
-/* DECIMAL SetValue: fill string with another string. */
-/***********************************************************************/
-void DECVAL::SetValue_psz(PSZ s)
- {
- if (s) {
- strncpy(Strp, s, Len);
- Null = false;
- } else {
- Reset();
- Null = Nullable;
- } // endif s
-
- } // end of SetValue_psz
-
-/***********************************************************************/
-/* DECIMAL SetValue: fill string with a string extracted from a block.*/
-/***********************************************************************/
-void DECVAL::SetValue_pvblk(PVBLK blk, int n)
- {
- // STRBLK's can return a NULL pointer
- SetValue_psz(blk->GetCharValue(n));
- } // end of SetValue_pvblk
-
-/***********************************************************************/
-/* DECIMAL SetBinValue: fill string with chars extracted from a line. */
-/***********************************************************************/
-void DECVAL::SetBinValue(void *p)
- {
- SetValue_char((char *)p, Len);
- } // end of SetBinValue
-
-/***********************************************************************/
-/* DECIMAL GetCharString: get string representation of a char value. */
-/***********************************************************************/
-char *DECVAL::GetCharString(char *p)
- {
- return Strp;
- } // end of GetCharString
-#endif // 0
-
/***********************************************************************/
/* DECIMAL compare value with another Value. */
/***********************************************************************/
@@ -1927,32 +1848,6 @@ int DECVAL::CompareValue(PVAL vp)
return (f > n) ? 1 : (f < n) ? (-1) : 0;
} // end of CompareValue
-#if 0
-/***********************************************************************/
-/* FormatValue: This function set vp (a STRING value) to the string */
-/* constructed from its own value formated using the fmt format. */
-/* This function assumes that the format matches the value type. */
-/***********************************************************************/
-bool DECVAL::FormatValue(PVAL vp, char *fmt)
- {
- char *buf = (char*)vp->GetTo_Val(); // Should be big enough
- int n = sprintf(buf, fmt, Strp);
-
- return (n > vp->GetValLen());
- } // end of FormatValue
-
-/***********************************************************************/
-/* DECIMAL SetFormat function (used to set SELECT output format). */
-/***********************************************************************/
-bool DECVAL::SetConstFormat(PGLOBAL g, FORMAT& fmt)
- {
- fmt.Type[0] = 'C';
- fmt.Length = Len;
- fmt.Prec = 0;
- return false;
- } // end of SetConstFormat
-#endif // 0
-
/* -------------------------- Class BINVAL --------------------------- */
/***********************************************************************/
@@ -2110,7 +2005,7 @@ bool BINVAL::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/
/* BINVAL SetValue: fill value with chars extracted from a line. */
/***********************************************************************/
-bool BINVAL::SetValue_char(char *p, int n)
+bool BINVAL::SetValue_char(const char *p, int n)
{
bool rc;
@@ -2131,7 +2026,7 @@ bool BINVAL::SetValue_char(char *p, int n)
/***********************************************************************/
/* BINVAL SetValue: fill value with another string. */
/***********************************************************************/
-void BINVAL::SetValue_psz(PSZ s)
+void BINVAL::SetValue_psz(PCSZ s)
{
if (s) {
Len = MY_MIN(Clen, (signed)strlen(s));
@@ -2357,7 +2252,7 @@ bool BINVAL::IsEqual(PVAL vp, bool chktype)
/* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */
/***********************************************************************/
-bool BINVAL::FormatValue(PVAL vp, char *fmt)
+bool BINVAL::FormatValue(PVAL vp, PCSZ fmt)
{
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
int n = sprintf(buf, fmt, Len, Binp);
@@ -2381,7 +2276,7 @@ bool BINVAL::SetConstFormat(PGLOBAL, FORMAT& fmt)
/***********************************************************************/
/* DTVAL public constructor for new void values. */
/***********************************************************************/
-DTVAL::DTVAL(PGLOBAL g, int n, int prec, PSZ fmt)
+DTVAL::DTVAL(PGLOBAL g, int n, int prec, PCSZ fmt)
: TYPVAL<int>((int)0, TYPE_DATE)
{
if (!fmt) {
@@ -2410,7 +2305,7 @@ DTVAL::DTVAL(int n) : TYPVAL<int>(n, TYPE_DATE)
/***********************************************************************/
/* Set format so formatted dates can be converted on input/output. */
/***********************************************************************/
-bool DTVAL::SetFormat(PGLOBAL g, PSZ fmt, int len, int year)
+bool DTVAL::SetFormat(PGLOBAL g, PCSZ fmt, int len, int year)
{
Pdtp = MakeDateFormat(g, fmt, true, true, (year > 9999) ? 1 : 0);
Sdate = (char*)PlugSubAlloc(g, NULL, len + 1);
@@ -2668,7 +2563,11 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
ndv = ExtractDate(valp->GetCharValue(), Pdtp, DefYear, dval);
MakeDate(NULL, dval, ndv);
- } else
+ } else if (valp->GetType() == TYPE_BIGINT &&
+ !(valp->GetBigintValue() % 1000)) {
+ // Assuming that this timestamp is in milliseconds
+ Tval = valp->GetBigintValue() / 1000;
+ } else
Tval = valp->GetIntValue();
} else
@@ -2682,14 +2581,14 @@ bool DTVAL::SetValue_pval(PVAL valp, bool chktype)
/***********************************************************************/
/* SetValue: convert chars extracted from a line to date value. */
/***********************************************************************/
-bool DTVAL::SetValue_char(char *p, int n)
+bool DTVAL::SetValue_char(const char *p, int n)
{
bool rc= 0;
if (Pdtp) {
- char *p2;
- int ndv;
- int dval[6];
+ const char *p2;
+ int ndv;
+ int dval[6];
if (n > 0) {
// Trim trailing blanks
@@ -2721,11 +2620,11 @@ bool DTVAL::SetValue_char(char *p, int n)
/***********************************************************************/
/* SetValue: convert a char string to date value. */
/***********************************************************************/
-void DTVAL::SetValue_psz(PSZ p)
+void DTVAL::SetValue_psz(PCSZ p)
{
if (Pdtp) {
- int ndv;
- int dval[6];
+ int ndv;
+ int dval[6];
strncpy(Sdate, p, Len);
Sdate[Len] = '\0';
@@ -2815,8 +2714,10 @@ char *DTVAL::ShowValue(char *buf, int len)
strncat(p, "Error", m);
} // endif n
- } else
- p = ""; // DEFAULT VALUE ???
+ } else {
+ p = buf;
+ *p = '\0'; // DEFAULT VALUE ???
+ } // endif Null
return p;
} else
@@ -2881,7 +2782,7 @@ bool DTVAL::WeekNum(PGLOBAL g, int& nval)
/* constructed from its own value formated using the fmt format. */
/* This function assumes that the format matches the value type. */
/***********************************************************************/
-bool DTVAL::FormatValue(PVAL vp, char *fmt)
+bool DTVAL::FormatValue(PVAL vp, PCSZ fmt)
{
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
struct tm tm, *ptm = GetGmTime(&tm);