- VarAnd, VarCmp (Strings only), VarNot implemented.

- VarParseNumFromStr/VarNumFromParseNum handle negative currency
  numbers.
- More VarCmp support (Decimals and Dates).
- Date support for VB time only (0.0->1.0), corrected some date
  rounding and calculation errors around variant dates and the system
  time.
- Variant date support now round trips! (Date->Variant->Date) due to
  misuse of tm_mon (0..11 not 1..12).
- Better pre-1899 support for dates in the SYSTEMTIME format.
- VarBstrFromCy, VarCyFromStr implemented.
- VarFormat partial implementation (currency and date support).
- VarFormatFromTokens, VarTokenizeFormatString partial implementation
  as per w2k (dates only so far).
- Better debugging when dumping variants, and some additional trace
 points to help debugging.
- Fix to VarBstrCmp to handle null and empty string the same (as per
  w2k, different to msdn).
- Fix return from VarDateFromUdate.
- Correct definition of CY structure.
This commit is contained in:
Jason Edmeades 2002-06-20 23:07:55 +00:00 committed by Alexandre Julliard
parent bc524e92d2
commit 5b6a9ff537
7 changed files with 1090 additions and 239 deletions

View file

@ -126,6 +126,7 @@ name oleaut32
136 stdcall VarUI1FromStr(wstr long long ptr) VarUI1FromStr
137 stub VarUI1FromDisp
138 stdcall VarUI1FromBool(long ptr) VarUI1FromBool
140 stdcall VarTokenizeFormatString (ptr ptr long long long long ptr) VarTokenizeFormatString
146 stub DispCallFunc
147 stdcall VariantChangeTypeEx(ptr ptr long long long) VariantChangeTypeEx
148 stdcall SafeArrayPtrOfIndex(ptr ptr ptr) SafeArrayPtrOfIndex
@ -306,11 +307,11 @@ name oleaut32
435 stub SafeArraySetRecordInfo
436 stub VarAbs # stdcall (ptr ptr)
437 stub VarAdd # stdcall (ptr ptr ptr)
438 stub VarAnd # stdcall (ptr ptr ptr)
438 stdcall VarAnd(ptr ptr ptr) VarAnd
439 stdcall VarBstrCat(ptr ptr ptr) VarBstrCat
440 stdcall VarBstrCmp(ptr ptr long long) VarBstrCmp
441 stdcall VarCat(ptr ptr ptr) VarCat
442 stub VarCmp # stdcall (ptr ptr long long)
442 stdcall VarCmp(ptr ptr long long) VarCmp
443 stub VarCyAbs
444 stub VarCyAdd
445 stub VarCyCmp
@ -337,10 +338,10 @@ name oleaut32
466 stub VarDiv # stdcall (ptr ptr ptr)
467 stub VarEqv # stdcall (ptr ptr ptr)
468 stub VarFix # stdcall (ptr ptr)
469 stub VarFormat # stdcall (ptr ptr long long long ptr)
469 stdcall VarFormat(ptr ptr long long long ptr) VarFormat
470 stub VarFormatCurrency # stdcall (ptr long long long long long ptr)
471 stub VarFormatDateTime # stdcall (ptr long long ptr)
472 stub VarFormatFromTokens # stdcall (ptr ptr ptr long ptr long)
472 stdcall VarFormatFromTokens (ptr ptr ptr long ptr long) VarFormatFromTokens
473 stub VarFormatNumber # stdcall (ptr long long long long long ptr)
474 stub VarFormatPercent # stdcall (ptr long long long long long ptr)
475 stub VarIdiv # stdcall (ptr ptr ptr)
@ -350,7 +351,7 @@ name oleaut32
479 stub VarMonthName # stdcall (long long long ptr)
480 stub VarMul # stdcall (ptr ptr ptr)
481 stub VarNeg # stdcall (ptr ptr)
482 stub VarNot # stdcall (ptr ptr)
482 stdcall VarNot(ptr ptr) VarNot
483 stub VarOr # stdcall (ptr ptr ptr)
484 stub VarPow # stdcall (ptr ptr ptr)
485 stub VarR4CmpR8
@ -358,6 +359,5 @@ name oleaut32
487 stub VarR8Round # stdcall (double long ptr)
488 stub VarRound # stdcall (ptr long ptr)
489 stub VarSub # stdcall (ptr ptr ptr)
490 stub VarTokenizeFormatString # stdcall (ptr ptr long long long long ptr)
491 stub VarWeekdayName # stdcall (long long long long ptr)
492 stub VarXor # stdcall (ptr ptr ptr)

View file

@ -79,6 +79,7 @@ int CTimeZone;
#define UTIME_MAXMONTH (01)
#define UTIME_MAXDAY (18)
/* Assumes month in 1..12. Note tm_mon is 0..11 */
#define IS_VALID_UTIME(y,m,d) (((y > UTIME_MINYEAR) \
|| ((y == UTIME_MINYEAR) && ((m > UTIME_MINMONTH) \
|| ((m == UTIME_MINMONTH) && (d >= UTIME_MINDAY))))) \
@ -600,7 +601,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
#ifdef DATEDEBUG
printf("DecodeDateTime- month field %s value is %d\n", field[i], val);
#endif
tm->tm_mon = val;
/* tm_mon is 0->11, so need to subtract one from value in table */
tm->tm_mon = val-1;
break;
/*
@ -680,9 +682,18 @@ DecodeDateTime(char **field, int *ftype, int nf,
else if ((mer == PM) && (tm->tm_hour != 12))
tm->tm_hour += 12;
/* If parsing a time string into a date, all date parts are unset.
Win2k defaults these to 30 dec, 1899 so: */
if (tm->tm_year == 0 && tm->tm_mon == 0 && tm->tm_mday == 0 && fmask == DTK_TIME_M) {
tm->tm_year = 1899;
tm->tm_mon = 11; /* December, as tm_mon is 0..11 */
tm->tm_mday = 30;
}
#ifdef DATEDEBUG
printf("DecodeDateTime- mask %08x (%08x)", fmask, DTK_DATE_M);
printf(" set y%04d m%02d d%02d", tm->tm_year, tm->tm_mon, tm->tm_mday);
printf(" set y%04d m%02d d%02d", tm->tm_year, (tm->tm_mon+1), tm->tm_mday);
printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
#endif
@ -701,7 +712,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
if (fmask & DTK_M(DTZMOD))
return -1;
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon+1, tm->tm_mday))
{
/* FIXME: The code below is not correct */
#if 0 /* defined(USE_POSIX_TIME) */
@ -909,7 +920,8 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm)
#ifdef DATEDEBUG
printf("DecodeDate- month field %s value is %d\n", field[i], val);
#endif
tm->tm_mon = val;
/* tm_mon is 0->11, so need to subtract one from value in table */
tm->tm_mon = val-1;
break;
default:
@ -1075,7 +1087,8 @@ DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double
printf("DecodeNumber- match %d (%s) as month\n", val, str);
#endif
*tmask = DTK_M(MONTH);
tm->tm_mon = val;
/* tm_mon is 0..11 */
tm->tm_mon = val-1;
/* no year and EuroDates enabled? then could be day */
}
@ -1097,7 +1110,8 @@ DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double
printf("DecodeNumber- (2) match %d (%s) as month\n", val, str);
#endif
*tmask = DTK_M(MONTH);
tm->tm_mon = val;
/* tm_mon is 0..11 */
tm->tm_mon = val-1;
}
else if ((!(fmask & DTK_M(DAY)))
@ -1149,7 +1163,7 @@ DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, dou
tm->tm_mday = atoi(str + 6);
*(str + 6) = '\0';
tm->tm_mon = atoi(str + 4);
tm->tm_mon = atoi(str + 4) - 1; /* tm_mon is 0..11 */
*(str + 4) = '\0';
tm->tm_year = atoi(str + 0);
@ -1181,7 +1195,7 @@ DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, dou
*tmask = DTK_DATE_M;
tm->tm_mday = atoi(str + 4);
*(str + 4) = '\0';
tm->tm_mon = atoi(str + 2);
tm->tm_mon = atoi(str + 2) - 1; /* tm_mon is 0..11 */
*(str + 2) = '\0';
tm->tm_year = atoi(str + 0);
}

View file

@ -45,6 +45,7 @@ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#include <stdlib.h>
#include <winnt.h> /* DateToTm use */
/* ----------------------------------------------------------------
* Section 1: bool, true, false, TRUE, FALSE
@ -367,6 +368,5 @@ int DecodeDateTime(char **field, int *ftype,
int DecodeTimeOnly(char **field, int *ftype, int nf,
int *dtype, struct tm * tm, double *fsec);
BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm );
#endif /* DT_H */

View file

@ -71,6 +71,7 @@
#include "ole2disp.h"
#include "typelib.h"
#include "wine/debug.h"
#include "parsedt.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
WINE_DECLARE_DEBUG_CHANNEL(typelib);
@ -1028,7 +1029,7 @@ static void dump_TLBImplType(TLBImplType * impl)
}
}
static void dump_Variant(VARIANT * pvar)
void dump_Variant(VARIANT * pvar)
{
char szVarType[32];
LPVOID ref;
@ -1061,7 +1062,7 @@ static void dump_Variant(VARIANT * pvar)
return;
}
switch (V_VT(pvar))
switch (V_VT(pvar) & VT_TYPEMASK)
{
case VT_I2:
TRACE("%d\n", *(short*)ref);
@ -1096,6 +1097,26 @@ static void dump_Variant(VARIANT * pvar)
if (V_VT(pvar) & VT_BYREF) dump_Variant(ref);
break;
case VT_DATE:
{
struct tm TM;
memset( &TM, 0, sizeof(TM) );
if( DateToTm( *(DATE*)ref, 0, &TM ) == FALSE ) {
TRACE("invalid date? (?)%ld %f\n", *(long*)ref, *(double *)ref);
} else {
TRACE("(yyyymmdd) %4.4d-%2.2d-%2.2d (time) %2.2d:%2.2d:%2.2d [%f]\n",
TM.tm_year, TM.tm_mon+1, TM.tm_mday,
TM.tm_hour, TM.tm_min, TM.tm_sec, *(double *)ref);
}
break;
}
case VT_CY:
TRACE("%ld (hi), %lu (lo)\n", ((CY *)ref)->s.Hi, ((CY *)ref)->s.Lo);
break;
default:
TRACE("(?)%ld\n", *(long*)ref);
break;

View file

@ -556,7 +556,7 @@ WORD typeofarray
*/
extern DWORD _invoke(LPVOID func,CALLCONV callconv, int nrargs, DWORD *args);
extern void dump_Variant(VARIANT * pvar);
#include "poppack.h"
/*---------------------------END--------------------------------------------*/

File diff suppressed because it is too large Load diff

View file

@ -168,7 +168,7 @@ typedef union tagCY {
struct {
#ifdef BIG_ENDIAN
LONG Hi;
LONG Lo;
ULONG Lo;
#else /* defined(BIG_ENDIAN) */
ULONG Lo;
LONG Hi;