ReactOS  0.4.14-dev-337-gf981a68
vartype.c File Reference
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winbase.h"
#include "winuser.h"
#include "winnt.h"
#include "variant.h"
#include "resource.h"
Include dependency graph for vartype.c:

Go to the source code of this file.

Classes

struct  DECIMAL_internal
 
union  R4_FIELDS
 
union  R8_FIELDS
 
struct  tagDATEPARSE
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define CY_MULTIPLIER   10000 /* 4 dp of precision */
 
#define CY_MULTIPLIER_F   10000.0
 
#define CY_HALF   (CY_MULTIPLIER/2) /* 0.5 */
 
#define CY_HALF_F   (CY_MULTIPLIER_F/2.0)
 
#define VARIANT_DutchRound(typ, value, res)
 
#define RETTYP   static inline HRESULT
 
#define SIMPLE(dest, src, func)
 
#define NEGTST(dest, src, func)
 
#define POSTST(dest, src, func, tst)
 
#define BOTHTST(dest, src, func, lo, hi)
 
#define DP_TIMESEP   0x01 /* Time separator ( _must_ remain 0x1, used as a bitmask) */
 
#define DP_DATESEP   0x02 /* Date separator */
 
#define DP_MONTH   0x04 /* Month name */
 
#define DP_AM   0x08 /* AM */
 
#define DP_PM   0x10 /* PM */
 
#define TIMEFLAG(i)   ((dp.dwFlags[i] & DP_TIMESEP) << i)
 
#define IsLeapYear(y)   (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
 
#define ORDER_MDY   0x01
 
#define ORDER_YMD   0x02
 
#define ORDER_YDM   0x04
 
#define ORDER_DMY   0x08
 
#define ORDER_MYD   0x10 /* Synthetic order, used only for funky 2 digit dates */
 
#define DATE_SWAP(x, y)   do { dwTemp = x; x = y; y = dwTemp; } while (0)
 

Typedefs

typedef struct DECIMAL_internal VARIANT_DI
 
typedef struct tagDATEPARSE DATEPARSE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (variant)
 
static void VARIANT_CopyData (const VARIANT *srcVar, VARTYPE vt, void *pOut)
 
static HRESULT VARIANT_NumberFromBstr (OLECHAR *pStrIn, LCID lcid, ULONG ulFlags, void *pOut, VARTYPE vt)
 
static HRESULT VARIANT_FromDisp (IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
 
RETTYP _VarR8FromCy (CY i, double *o)
 
HRESULT WINAPI VarI1FromUI1 (BYTE bIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI2 (SHORT sIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI4 (LONG iIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromR4 (FLOAT fltIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromR8 (double dblIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDate (DATE dateIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromCy (CY cyIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDisp (IDispatch *pdispIn, LCID lcid, signed char *pcOut)
 
HRESULT WINAPI VarI1FromBool (VARIANT_BOOL boolIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI2 (USHORT usIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI4 (ULONG ulIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDec (DECIMAL *pdecIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI8 (LONG64 llIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI8 (ULONG64 ullIn, signed char *pcOut)
 
HRESULT WINAPI VarUI1FromI2 (SHORT sIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI4 (LONG iIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromR4 (FLOAT fltIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromR8 (double dblIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromCy (CY cyIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDate (DATE dateIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDisp (IDispatch *pdispIn, LCID lcid, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromBool (VARIANT_BOOL boolIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI1 (signed char cIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI2 (USHORT usIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI4 (ULONG ulIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDec (DECIMAL *pdecIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI8 (LONG64 llIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI8 (ULONG64 ullIn, BYTE *pbOut)
 
HRESULT WINAPI VarI2FromUI1 (BYTE bIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI4 (LONG iIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromR4 (FLOAT fltIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromR8 (double dblIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromCy (CY cyIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDate (DATE dateIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDisp (IDispatch *pdispIn, LCID lcid, SHORT *psOut)
 
HRESULT WINAPI VarI2FromBool (VARIANT_BOOL boolIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI1 (signed char cIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI2 (USHORT usIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI4 (ULONG ulIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDec (DECIMAL *pdecIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI8 (LONG64 llIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI8 (ULONG64 ullIn, SHORT *psOut)
 
HRESULT WINAPI VarUI2FromUI1 (BYTE bIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI2 (SHORT sIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI4 (LONG iIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromR4 (FLOAT fltIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromR8 (double dblIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDate (DATE dateIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromCy (CY cyIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDisp (IDispatch *pdispIn, LCID lcid, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromBool (VARIANT_BOOL boolIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI1 (signed char cIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromUI4 (ULONG ulIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDec (DECIMAL *pdecIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI8 (LONG64 llIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromUI8 (ULONG64 ullIn, USHORT *pusOut)
 
HRESULT WINAPI VarI4FromUI1 (BYTE bIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI2 (SHORT sIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromR4 (FLOAT fltIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromR8 (double dblIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromCy (CY cyIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromDate (DATE dateIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG *piOut)
 
HRESULT WINAPI VarI4FromDisp (IDispatch *pdispIn, LCID lcid, LONG *piOut)
 
HRESULT WINAPI VarI4FromBool (VARIANT_BOOL boolIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI1 (signed char cIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI2 (USHORT usIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI4 (ULONG ulIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromDec (DECIMAL *pdecIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI8 (LONG64 llIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI8 (ULONG64 ullIn, LONG *piOut)
 
HRESULT WINAPI VarUI4FromUI1 (BYTE bIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI2 (SHORT sIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI4 (LONG iIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromR4 (FLOAT fltIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromR8 (double dblIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDate (DATE dateIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromCy (CY cyIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDisp (IDispatch *pdispIn, LCID lcid, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromBool (VARIANT_BOOL boolIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI1 (signed char cIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromUI2 (USHORT usIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDec (DECIMAL *pdecIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI8 (LONG64 llIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromUI8 (ULONG64 ullIn, ULONG *pulOut)
 
HRESULT WINAPI VarI8FromUI1 (BYTE bIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromI2 (SHORT sIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromR4 (FLOAT fltIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromR8 (double dblIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromCy (CY cyIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDate (DATE dateIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDisp (IDispatch *pdispIn, LCID lcid, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromBool (VARIANT_BOOL boolIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromI1 (signed char cIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI2 (USHORT usIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI4 (ULONG ulIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDec (DECIMAL *pdecIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI8 (ULONG64 ullIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarUI8FromI8 (LONG64 llIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI1 (BYTE bIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromI2 (SHORT sIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromR4 (FLOAT fltIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromR8 (double dblIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromCy (CY cyIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDate (DATE dateIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDisp (IDispatch *pdispIn, LCID lcid, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromBool (VARIANT_BOOL boolIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromI1 (signed char cIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI2 (USHORT usIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI4 (ULONG ulIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDec (DECIMAL *pdecIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarR4FromUI1 (BYTE bIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI2 (SHORT sIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI4 (LONG lIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromR8 (double dblIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromCy (CY cyIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromDate (DATE dateIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, float *pFltOut)
 
HRESULT WINAPI VarR4FromDisp (IDispatch *pdispIn, LCID lcid, float *pFltOut)
 
HRESULT WINAPI VarR4FromBool (VARIANT_BOOL boolIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI1 (signed char cIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI2 (USHORT usIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI4 (ULONG ulIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromDec (DECIMAL *pDecIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI8 (LONG64 llIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI8 (ULONG64 ullIn, float *pFltOut)
 
HRESULT WINAPI VarR4CmpR8 (float fltLeft, double dblRight)
 
HRESULT WINAPI VarR8FromUI1 (BYTE bIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI2 (SHORT sIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI4 (LONG lIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromR4 (FLOAT fltIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromCy (CY cyIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromDate (DATE dateIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
 
HRESULT WINAPI VarR8FromDisp (IDispatch *pdispIn, LCID lcid, double *pDblOut)
 
HRESULT WINAPI VarR8FromBool (VARIANT_BOOL boolIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI1 (signed char cIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI2 (USHORT usIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI4 (ULONG ulIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromDec (const DECIMAL *pDecIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI8 (LONG64 llIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI8 (ULONG64 ullIn, double *pDblOut)
 
HRESULT WINAPI VarR8Pow (double dblLeft, double dblPow, double *pDblOut)
 
HRESULT WINAPI VarR8Round (double dblIn, int nDig, double *pDblOut)
 
HRESULT WINAPI VarCyFromUI1 (BYTE bIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI2 (SHORT sIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI4 (LONG lIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromR4 (FLOAT fltIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromR8 (double dblIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDate (DATE dateIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDisp (IDispatch *pdispIn, LCID lcid, CY *pCyOut)
 
HRESULT WINAPI VarCyFromBool (VARIANT_BOOL boolIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI1 (signed char cIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI2 (USHORT usIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI4 (ULONG ulIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDec (DECIMAL *pdecIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI8 (LONG64 llIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI8 (ULONG64 ullIn, CY *pCyOut)
 
HRESULT WINAPI VarCyAdd (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyMul (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyMulI4 (CY cyLeft, LONG lRight, CY *pCyOut)
 
HRESULT WINAPI VarCySub (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyAbs (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFix (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyInt (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyNeg (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyRound (CY cyIn, int cDecimals, CY *pCyOut)
 
HRESULT WINAPI VarCyCmp (CY cyLeft, CY cyRight)
 
HRESULT WINAPI VarCyCmpR8 (CY cyLeft, double dblRight)
 
HRESULT WINAPI VarCyMulI8 (CY cyLeft, LONG64 llRight, CY *pCyOut)
 
HRESULT WINAPI VarDecFromUI1 (BYTE bIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI2 (SHORT sIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI4 (LONG lIn, DECIMAL *pDecOut)
 
static HRESULT VARIANT_DI_FromR4 (float source, VARIANT_DI *dest)
 
static HRESULT VARIANT_DI_FromR8 (double source, VARIANT_DI *dest)
 
static void VARIANT_DIFromDec (const DECIMAL *from, VARIANT_DI *to)
 
static void VARIANT_DecFromDI (const VARIANT_DI *from, DECIMAL *to)
 
static unsigned char VARIANT_int_divbychar (DWORD *p, unsigned int n, unsigned char divisor)
 
static BOOL VARIANT_int_iszero (const DWORD *p, unsigned int n)
 
HRESULT WINAPI VarDecFromR4 (FLOAT fltIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromR8 (double dblIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromDate (DATE dateIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromCy (CY cyIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromDisp (IDispatch *pdispIn, LCID lcid, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromBool (VARIANT_BOOL bIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI1 (signed char cIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI2 (USHORT usIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI4 (ULONG ulIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI8 (LONG64 llIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI8 (ULONG64 ullIn, DECIMAL *pDecOut)
 
static HRESULT VARIANT_DecScale (const DECIMAL **ppDecLeft, const DECIMAL **ppDecRight, DECIMAL pDecOut[2])
 
static ULONG VARIANT_Add (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static ULONG VARIANT_Sub (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static ULONG VARIANT_Mul (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static int VARIANT_DecCmp (const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
 
HRESULT WINAPI VarDecAdd (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
static void VARIANT_DI_clear (VARIANT_DI *i)
 
static int VARIANT_DI_mul (const VARIANT_DI *a, const VARIANT_DI *b, VARIANT_DI *result)
 
static BOOL VARIANT_DI_tostringW (const VARIANT_DI *a, WCHAR *s, unsigned int n)
 
static void VARIANT_int_shiftleft (DWORD *p, unsigned int n, unsigned int shift)
 
static unsigned char VARIANT_int_add (DWORD *v, unsigned int nv, const DWORD *p, unsigned int np)
 
static void VARIANT_int_div (DWORD *p, unsigned int n, const DWORD *divisor, unsigned int dn)
 
static unsigned char VARIANT_int_mulbychar (DWORD *p, unsigned int n, unsigned char m)
 
static int VARIANT_int_addlossy (DWORD *a, int *ascale, unsigned int an, DWORD *b, int *bscale, unsigned int bn)
 
static HRESULT VARIANT_DI_div (const VARIANT_DI *dividend, const VARIANT_DI *divisor, VARIANT_DI *quotient, BOOL round_remainder)
 
static HRESULT VARIANT_DI_normalize (VARIANT_DI *val, int exponent2, BOOL isDouble)
 
static HRESULT VARIANT_do_division (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut, BOOL round)
 
HRESULT WINAPI VarDecDiv (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecMul (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecSub (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecAbs (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFix (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecInt (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecNeg (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecRound (const DECIMAL *pDecIn, int cDecimals, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecCmp (const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
 
HRESULT WINAPI VarDecCmpR8 (const DECIMAL *pDecLeft, double dblRight)
 
HRESULT WINAPI VarBoolFromUI1 (BYTE bIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI2 (SHORT sIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI4 (LONG lIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromR4 (FLOAT fltIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromR8 (double dblIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDate (DATE dateIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromCy (CY cyIn, VARIANT_BOOL *pBoolOut)
 
static BOOL VARIANT_GetLocalisedText (LANGID langId, DWORD dwId, WCHAR *lpszDest)
 
HRESULT WINAPI VarBoolFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDisp (IDispatch *pdispIn, LCID lcid, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI1 (signed char cIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI2 (USHORT usIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI4 (ULONG ulIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDec (DECIMAL *pDecIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI8 (LONG64 llIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI8 (ULONG64 ullIn, VARIANT_BOOL *pBoolOut)
 
static WCHARVARIANT_WriteNumber (ULONG64 ulVal, WCHAR *szOut)
 
static BSTR VARIANT_MakeBstr (LCID lcid, DWORD dwFlags, WCHAR *szOut)
 
static HRESULT VARIANT_BstrFromUInt (ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI1 (BYTE bIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI2 (short sIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI4 (LONG lIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
static BSTR VARIANT_BstrReplaceDecimal (const WCHAR *buff, LCID lcid, ULONG dwFlags)
 
static HRESULT VARIANT_BstrFromReal (DOUBLE dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut, LPCWSTR lpszFormat)
 
HRESULT WINAPI VarBstrFromR4 (FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromR8 (double dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromCy (CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
static int output_int_len (int o, int min_len, WCHAR *date, int date_len)
 
BOOL get_date_format (LCID lcid, DWORD flags, const SYSTEMTIME *st, const WCHAR *fmt, WCHAR *date, int date_len)
 
HRESULT WINAPI VarBstrFromDate (DATE dateIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromBool (VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI1 (signed char cIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI2 (USHORT usIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI4 (ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromDec (DECIMAL *pDecIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI8 (LONG64 llIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI8 (ULONG64 ullIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromDisp (IDispatch *pdispIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrCat (BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrCmp (BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFlags)
 
HRESULT WINAPI VarDateFromUI1 (BYTE bIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI2 (short sIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI4 (LONG lIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromR4 (FLOAT fltIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromR8 (double dblIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromDisp (IDispatch *pdispIn, LCID lcid, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromBool (VARIANT_BOOL boolIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromCy (CY cyIn, DATE *pdateOut)
 
static BOOL VARIANT_IsValidMonthDay (DWORD day, DWORD month, DWORD year)
 
static HRESULT VARIANT_MakeDate (DATEPARSE *dp, DWORD iDate, DWORD offset, SYSTEMTIME *st)
 
HRESULT WINAPI VarDateFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI1 (signed char cIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI2 (USHORT uiIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI4 (ULONG ulIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromDec (DECIMAL *pdecIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI8 (LONG64 llIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI8 (ULONG64 ullIn, DATE *pdateOut)
 

Variables

HMODULE hProxyDll DECLSPEC_HIDDEN
 
static const WCHAR szFloatFormatW [] = { '%','.','7','G','\0' }
 
static const WCHAR szDoubleFormatW [] = { '%','.','1','5','G','\0' }
 
static const int CY_Divisors [5]
 

Macro Definition Documentation

◆ BOTHTST

#define BOTHTST (   dest,
  src,
  func,
  lo,
  hi 
)
Value:
if (in < (dest)lo || in > hi) return DISP_E_OVERFLOW; *out = in; return S_OK; }
GLenum func
Definition: glext.h:6028
#define RETTYP
Definition: vartype.c:145
#define _(X)
Definition: i386-dis.c:36
static FILE * out
Definition: regtests2xml.c:44
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:59
GLuint in
Definition: glext.h:9616
static char * dest
Definition: rtl.c:135
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Definition at line 161 of file vartype.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file vartype.c.

◆ CY_HALF

#define CY_HALF   (CY_MULTIPLIER/2) /* 0.5 */

Definition at line 39 of file vartype.c.

◆ CY_HALF_F

#define CY_HALF_F   (CY_MULTIPLIER_F/2.0)

Definition at line 40 of file vartype.c.

◆ CY_MULTIPLIER

#define CY_MULTIPLIER   10000 /* 4 dp of precision */

Definition at line 37 of file vartype.c.

◆ CY_MULTIPLIER_F

#define CY_MULTIPLIER_F   10000.0

Definition at line 38 of file vartype.c.

◆ DATE_SWAP

#define DATE_SWAP (   x,
  y 
)    do { dwTemp = x; x = y; y = dwTemp; } while (0)

◆ DP_AM

#define DP_AM   0x08 /* AM */

Definition at line 7357 of file vartype.c.

◆ DP_DATESEP

#define DP_DATESEP   0x02 /* Date separator */

Definition at line 7355 of file vartype.c.

◆ DP_MONTH

#define DP_MONTH   0x04 /* Month name */

Definition at line 7356 of file vartype.c.

◆ DP_PM

#define DP_PM   0x10 /* PM */

Definition at line 7358 of file vartype.c.

◆ DP_TIMESEP

#define DP_TIMESEP   0x01 /* Time separator ( _must_ remain 0x1, used as a bitmask) */

Definition at line 7354 of file vartype.c.

◆ IsLeapYear

#define IsLeapYear (   y)    (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))

Definition at line 7370 of file vartype.c.

◆ NEGTST

#define NEGTST (   dest,
  src,
  func 
)
Value:
GLenum func
Definition: glext.h:6028
return
Definition: dirsup.c:529
#define RETTYP
Definition: vartype.c:145
#define _(X)
Definition: i386-dis.c:36
static FILE * out
Definition: regtests2xml.c:44
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:59
GLuint in
Definition: glext.h:9616
static char * dest
Definition: rtl.c:135
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Definition at line 153 of file vartype.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 23 of file vartype.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 22 of file vartype.c.

◆ ORDER_DMY

#define ORDER_DMY   0x08

Definition at line 7389 of file vartype.c.

◆ ORDER_MDY

#define ORDER_MDY   0x01

Definition at line 7386 of file vartype.c.

◆ ORDER_MYD

#define ORDER_MYD   0x10 /* Synthetic order, used only for funky 2 digit dates */

Definition at line 7390 of file vartype.c.

◆ ORDER_YDM

#define ORDER_YDM   0x04

Definition at line 7388 of file vartype.c.

◆ ORDER_YMD

#define ORDER_YMD   0x02

Definition at line 7387 of file vartype.c.

◆ POSTST

#define POSTST (   dest,
  src,
  func,
  tst 
)
Value:
if (in > (dest)tst) return DISP_E_OVERFLOW; *out = in; return S_OK; }
GLenum func
Definition: glext.h:6028
#define RETTYP
Definition: vartype.c:145
#define _(X)
Definition: i386-dis.c:36
static FILE * out
Definition: regtests2xml.c:44
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:59
GLuint in
Definition: glext.h:9616
static char * dest
Definition: rtl.c:135
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Definition at line 157 of file vartype.c.

◆ RETTYP

#define RETTYP   static inline HRESULT

Definition at line 145 of file vartype.c.

◆ SIMPLE

#define SIMPLE (   dest,
  src,
  func 
)
Value:
*out = in; return S_OK; }
GLenum func
Definition: glext.h:6028
#define RETTYP
Definition: vartype.c:145
#define _(X)
Definition: i386-dis.c:36
static FILE * out
Definition: regtests2xml.c:44
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:59
GLuint in
Definition: glext.h:9616
static char * dest
Definition: rtl.c:135

Definition at line 149 of file vartype.c.

◆ TIMEFLAG

#define TIMEFLAG (   i)    ((dp.dwFlags[i] & DP_TIMESEP) << i)

Definition at line 7368 of file vartype.c.

◆ VARIANT_DutchRound

#define VARIANT_DutchRound (   typ,
  value,
  res 
)
Value:
do { \
double whole = value < 0 ? ceil(value) : floor(value); \
double fract = value - whole; \
if (fract > 0.5) res = (typ)whole + (typ)1; \
else if (fract == 0.5) { typ is_odd = (typ)whole & 1; res = whole + is_odd; } \
else if (fract >= 0.0) res = (typ)whole; \
else if (fract == -0.5) { typ is_odd = (typ)whole & 1; res = whole - is_odd; } \
else if (fract > -0.5) res = (typ)whole; \
else res = (typ)whole - (typ)1; \
} while(0)
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
else
Definition: tritemp.h:161
if(!(yy_init))
Definition: macro.lex.yy.c:714
GLuint res
Definition: glext.h:9613
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)

Definition at line 76 of file vartype.c.

Typedef Documentation

◆ DATEPARSE

◆ VARIANT_DI

Function Documentation

◆ _VarR8FromCy()

RETTYP _VarR8FromCy ( CY  i,
double o 
)

Definition at line 254 of file vartype.c.

254 { *o = (double)i.int64 / CY_MULTIPLIER_F; return S_OK; }
#define CY_MULTIPLIER_F
Definition: vartype.c:38
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define S_OK
Definition: intsafe.h:59

Referenced by VarCyAdd(), VarCyMul(), VarCyMulI4(), VarCyMulI8(), VarCyRound(), VarCySub(), and VarR8FromCy().

◆ get_date_format()

BOOL get_date_format ( LCID  lcid,
DWORD  flags,
const SYSTEMTIME st,
const WCHAR fmt,
WCHAR date,
int  date_len 
)

Definition at line 6667 of file vartype.c.

6669 {
6670  static const LCTYPE dayname[] = {
6673  };
6674  static const LCTYPE sdayname[] = {
6678  };
6679  static const LCTYPE monthname[] = {
6683  };
6684  static const LCTYPE smonthname[] = {
6689  };
6690 
6692  FIXME("ignoring flags %x\n", flags);
6694 
6695  while(*fmt && date_len) {
6696  int count = 1;
6697 
6698  switch(*fmt) {
6699  case 'd':
6700  case 'M':
6701  case 'y':
6702  case 'g':
6703  while(*fmt == *(fmt+count))
6704  count++;
6705  fmt += count-1;
6706  }
6707 
6708  switch(*fmt) {
6709  case 'd':
6710  if(count >= 4)
6711  count = GetLocaleInfoW(lcid, dayname[st->wDayOfWeek] | flags, date, date_len)-1;
6712  else if(count == 3)
6713  count = GetLocaleInfoW(lcid, sdayname[st->wDayOfWeek] | flags, date, date_len)-1;
6714  else
6715  count = output_int_len(st->wDay, count, date, date_len);
6716  break;
6717  case 'M':
6718  if(count >= 4)
6719  count = GetLocaleInfoW(lcid, monthname[st->wMonth-1] | flags, date, date_len)-1;
6720  else if(count == 3)
6721  count = GetLocaleInfoW(lcid, smonthname[st->wMonth-1] | flags, date, date_len)-1;
6722  else
6723  count = output_int_len(st->wMonth, count, date, date_len);
6724  break;
6725  case 'y':
6726  if(count >= 3)
6727  count = output_int_len(st->wYear, 0, date, date_len);
6728  else
6729  count = output_int_len(st->wYear%100, count, date, date_len);
6730  break;
6731  case 'g':
6732  if(count == 2) {
6733  FIXME("Should be using GetCalendarInfo(CAL_SERASTRING), defaulting to 'AD'\n");
6734 
6735  *date++ = 'A';
6736  date_len--;
6737  if(date_len)
6738  *date = 'D';
6739  else
6740  count = -1;
6741  break;
6742  }
6743  /* fall through */
6744  default:
6745  *date = *fmt;
6746  }
6747 
6748  if(count < 0)
6749  break;
6750  fmt++;
6751  date += count;
6752  date_len -= count;
6753  }
6754 
6755  if(!date_len)
6756  return FALSE;
6757  *date++ = 0;
6758  return TRUE;
6759 }
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define TRUE
Definition: types.h:120
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
WORD wMonth
Definition: winbase.h:878
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
GLuint GLuint GLsizei count
Definition: gl.h:1545
WORD wDayOfWeek
Definition: winbase.h:879
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
const char * fmt
Definition: wsprintf.c:30
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
WORD wYear
Definition: winbase.h:877
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
DWORD LCTYPE
Definition: winnls.h:514
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define FIXME(fmt,...)
Definition: debug.h:110
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
GLbitfield flags
Definition: glext.h:7161
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
WORD wDay
Definition: winbase.h:880
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
__u16 date
Definition: mkdosfs.c:366
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
static int output_int_len(int o, int min_len, WCHAR *date, int date_len)
Definition: vartype.c:6647
Definition: dsound.c:943

Referenced by VarBstrFromDate(), and VARIANT_FormatDate().

◆ output_int_len()

static int output_int_len ( int  o,
int  min_len,
WCHAR date,
int  date_len 
)
inlinestatic

Definition at line 6647 of file vartype.c.

6648 {
6649  int len, tmp;
6650 
6651  if(min_len >= date_len)
6652  return -1;
6653 
6654  for(len=0, tmp=o; tmp; tmp/=10) len++;
6655  if(!len) len++;
6656  if(len >= date_len)
6657  return -1;
6658 
6659  for(tmp=min_len-len; tmp>0; tmp--)
6660  *date++ = '0';
6661  for(tmp=len; tmp>0; tmp--, o/=10)
6662  date[tmp-1] = '0' + o%10;
6663  return min_len>len ? min_len : len;
6664 }
GLenum GLsizei len
Definition: glext.h:6722
__u16 date
Definition: mkdosfs.c:366

Referenced by get_date_format().

◆ VarBoolFromCy()

HRESULT WINAPI VarBoolFromCy ( CY  cyIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6047 of file vartype.c.

6048 {
6049  *pBoolOut = cyIn.int64 ? VARIANT_TRUE : VARIANT_FALSE;
6050  return S_OK;
6051 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromCy(), and VARIANT_Coerce().

◆ VarBoolFromDate()

HRESULT WINAPI VarBoolFromDate ( DATE  dateIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6029 of file vartype.c.

6030 {
6031  *pBoolOut = dateIn ? VARIANT_TRUE : VARIANT_FALSE;
6032  return S_OK;
6033 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromDate(), and VARIANT_Coerce().

◆ VarBoolFromDec()

HRESULT WINAPI VarBoolFromDec ( DECIMAL pDecIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6277 of file vartype.c.

6278 {
6279  if (DEC_SCALE(pDecIn) > DEC_MAX_SCALE || (DEC_SIGN(pDecIn) & ~DECIMAL_NEG))
6280  return E_INVALIDARG;
6281 
6282  if (DEC_HI32(pDecIn) || DEC_MID32(pDecIn) || DEC_LO32(pDecIn))
6283  *pBoolOut = VARIANT_TRUE;
6284  else
6285  *pBoolOut = VARIANT_FALSE;
6286  return S_OK;
6287 }
#define DEC_LO32(d)
Definition: variant.h:96
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DEC_MAX_SCALE
Definition: variant.h:99
#define DEC_SIGN(d)
Definition: variant.h:91
#define DEC_HI32(d)
Definition: variant.h:94
#define S_OK
Definition: intsafe.h:59
#define DEC_SCALE(d)
Definition: variant.h:92
#define DEC_MID32(d)
Definition: variant.h:95

Referenced by test_VarBoolFromDec(), and VARIANT_Coerce().

◆ VarBoolFromDisp()

HRESULT WINAPI VarBoolFromDisp ( IDispatch pdispIn,
LCID  lcid,
VARIANT_BOOL pBoolOut 
)

Definition at line 6205 of file vartype.c.

6206 {
6207  return VARIANT_FromDisp(pdispIn, lcid, pBoolOut, VT_BOOL, 0);
6208 }
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:114

Referenced by VARIANT_Coerce().

◆ VarBoolFromI1()

HRESULT WINAPI VarBoolFromI1 ( signed char  cIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6222 of file vartype.c.

6223 {
6224  *pBoolOut = cIn ? VARIANT_TRUE : VARIANT_FALSE;
6225  return S_OK;
6226 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromI1(), and VARIANT_Coerce().

◆ VarBoolFromI2()

HRESULT WINAPI VarBoolFromI2 ( SHORT  sIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5957 of file vartype.c.

5958 {
5959  *pBoolOut = sIn ? VARIANT_TRUE : VARIANT_FALSE;
5960  return S_OK;
5961 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromI2(), and VARIANT_Coerce().

◆ VarBoolFromI4()

HRESULT WINAPI VarBoolFromI4 ( LONG  lIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5975 of file vartype.c.

5976 {
5977  *pBoolOut = lIn ? VARIANT_TRUE : VARIANT_FALSE;
5978  return S_OK;
5979 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromI4(), test_VarBoolFromUI4(), and VARIANT_Coerce().

◆ VarBoolFromI8()

HRESULT WINAPI VarBoolFromI8 ( LONG64  llIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6301 of file vartype.c.

6302 {
6303  *pBoolOut = llIn ? VARIANT_TRUE : VARIANT_FALSE;
6304  return S_OK;
6305 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromI8(), and VARIANT_Coerce().

◆ VarBoolFromR4()

HRESULT WINAPI VarBoolFromR4 ( FLOAT  fltIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5993 of file vartype.c.

5994 {
5995  *pBoolOut = fltIn ? VARIANT_TRUE : VARIANT_FALSE;
5996  return S_OK;
5997 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromR4(), and VARIANT_Coerce().

◆ VarBoolFromR8()

HRESULT WINAPI VarBoolFromR8 ( double  dblIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6011 of file vartype.c.

6012 {
6013  *pBoolOut = dblIn ? VARIANT_TRUE : VARIANT_FALSE;
6014  return S_OK;
6015 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromR8(), and VARIANT_Coerce().

◆ VarBoolFromStr()

HRESULT WINAPI VarBoolFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
VARIANT_BOOL pBoolOut 
)

Definition at line 6113 of file vartype.c.

6114 {
6115  /* Any VB/VBA programmers out there should recognise these strings... */
6116  static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
6117  static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
6118  WCHAR szBuff[64];
6120  HRESULT hRes = S_OK;
6121 
6122  if (!strIn || !pBoolOut)
6123  return DISP_E_TYPEMISMATCH;
6124 
6125  /* Check if we should be comparing against localised text */
6126  if (dwFlags & VAR_LOCALBOOL)
6127  {
6128  /* Convert our LCID into a usable value */
6129  lcid = ConvertDefaultLocale(lcid);
6130 
6131  langId = LANGIDFROMLCID(lcid);
6132 
6133  if (PRIMARYLANGID(langId) == LANG_NEUTRAL)
6135 
6136  /* Note: Native oleaut32 always copies strIn and maps halfwidth characters.
6137  * I don't think this is needed unless any of the localised text strings
6138  * contain characters that can be so mapped. In the event that this is
6139  * true for a given language (possibly some Asian languages), then strIn
6140  * should be mapped here _only_ if langId is an Id for which this can occur.
6141  */
6142  }
6143 
6144  /* Note that if we are not comparing against localised strings, langId
6145  * will have its default value of LANG_ENGLISH. This allows us to mimic
6146  * the native behaviour of always checking against English strings even
6147  * after we've checked for localised ones.
6148  */
6149 VarBoolFromStr_CheckLocalised:
6150  if (VARIANT_GetLocalisedText(langId, IDS_TRUE, szBuff))
6151  {
6152  /* Compare against localised strings, ignoring case */
6153  if (!strcmpiW(strIn, szBuff))
6154  {
6155  *pBoolOut = VARIANT_TRUE; /* Matched localised 'true' text */
6156  return hRes;
6157  }
6158  VARIANT_GetLocalisedText(langId, IDS_FALSE, szBuff);
6159  if (!strcmpiW(strIn, szBuff))
6160  {
6161  *pBoolOut = VARIANT_FALSE; /* Matched localised 'false' text */
6162  return hRes;
6163  }
6164  }
6165 
6166  if (langId != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT))
6167  {
6168  /* We have checked the localised text, now check English */
6170  goto VarBoolFromStr_CheckLocalised;
6171  }
6172 
6173  /* All checks against localised text have failed, try #TRUE#/#FALSE# */
6174  if (!strcmpW(strIn, szFalse))
6175  *pBoolOut = VARIANT_FALSE;
6176  else if (!strcmpW(strIn, szTrue))
6177  *pBoolOut = VARIANT_TRUE;
6178  else
6179  {
6180  double d;
6181 
6182  /* If this string is a number, convert it as one */
6183  hRes = VarR8FromStr(strIn, lcid, dwFlags, &d);
6184  if (SUCCEEDED(hRes)) *pBoolOut = d ? VARIANT_TRUE : VARIANT_FALSE;
6185  }
6186  return hRes;
6187 }
#define LANG_NEUTRAL
Definition: nls.h:22
static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest)
Definition: vartype.c:6059
#define SUBLANG_DEFAULT
Definition: nls.h:168
WORD LANGID
Definition: typedefs.h:79
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3150
#define IDS_TRUE
Definition: resource.h:26
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: lang.c:1502
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDS_FALSE
Definition: resource.h:27
LONG HRESULT
Definition: typedefs.h:77
#define LANG_ENGLISH
Definition: nls.h:52
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define VAR_LOCALBOOL
Definition: oleauto.h:330
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by test_VarBoolFromStr(), VarAnd(), VARIANT_Coerce(), VarImp(), VarNot(), and VarOr().

◆ VarBoolFromUI1()

HRESULT WINAPI VarBoolFromUI1 ( BYTE  bIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5939 of file vartype.c.

5940 {
5941  *pBoolOut = bIn ? VARIANT_TRUE : VARIANT_FALSE;
5942  return S_OK;
5943 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromUI1(), and VARIANT_Coerce().

◆ VarBoolFromUI2()

HRESULT WINAPI VarBoolFromUI2 ( USHORT  usIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6240 of file vartype.c.

6241 {
6242  *pBoolOut = usIn ? VARIANT_TRUE : VARIANT_FALSE;
6243  return S_OK;
6244 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromUI2(), and VARIANT_Coerce().

◆ VarBoolFromUI4()

HRESULT WINAPI VarBoolFromUI4 ( ULONG  ulIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6258 of file vartype.c.

6259 {
6260  *pBoolOut = ulIn ? VARIANT_TRUE : VARIANT_FALSE;
6261  return S_OK;
6262 }
#define S_OK
Definition: intsafe.h:59

Referenced by VARIANT_Coerce().

◆ VarBoolFromUI8()

HRESULT WINAPI VarBoolFromUI8 ( ULONG64  ullIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6319 of file vartype.c.

6320 {
6321  *pBoolOut = ullIn ? VARIANT_TRUE : VARIANT_FALSE;
6322  return S_OK;
6323 }
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBoolFromUI8(), and VARIANT_Coerce().

◆ VarBstrCat()

HRESULT WINAPI VarBstrCat ( BSTR  pbstrLeft,
BSTR  pbstrRight,
BSTR pbstrOut 
)

Definition at line 7106 of file vartype.c.

7107 {
7108  unsigned int lenLeft, lenRight;
7109 
7110  TRACE("%s,%s,%p\n",
7111  debugstr_wn(pbstrLeft, SysStringLen(pbstrLeft)),
7112  debugstr_wn(pbstrRight, SysStringLen(pbstrRight)), pbstrOut);
7113 
7114  if (!pbstrOut)
7115  return E_INVALIDARG;
7116 
7117  /* use byte length here to properly handle ansi-allocated BSTRs */
7118  lenLeft = pbstrLeft ? SysStringByteLen(pbstrLeft) : 0;
7119  lenRight = pbstrRight ? SysStringByteLen(pbstrRight) : 0;
7120 
7121  *pbstrOut = SysAllocStringByteLen(NULL, lenLeft + lenRight);
7122  if (!*pbstrOut)
7123  return E_OUTOFMEMORY;
7124 
7125  (*pbstrOut)[0] = '\0';
7126 
7127  if (pbstrLeft)
7128  memcpy(*pbstrOut, pbstrLeft, lenLeft);
7129 
7130  if (pbstrRight)
7131  memcpy((CHAR*)*pbstrOut + lenLeft, pbstrRight, lenRight);
7132 
7133  TRACE("%s\n", debugstr_wn(*pbstrOut, SysStringLen(*pbstrOut)));
7134  return S_OK;
7135 }
char CHAR
Definition: xmlstorage.h:175
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:218
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI DECLSPEC_HOTPATCH SysAllocStringByteLen(LPCSTR str, UINT len)
Definition: oleaut.c:431
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:199
#define debugstr_wn
Definition: kernel32.h:33
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarBstrCat(), VarAdd(), and VarCat().

◆ VarBstrCmp()

HRESULT WINAPI VarBstrCmp ( BSTR  pbstrLeft,
BSTR  pbstrRight,
LCID  lcid,
DWORD  dwFlags 
)

Definition at line 7157 of file vartype.c.

7158 {
7159  HRESULT hres;
7160  int ret;
7161 
7162  TRACE("%s,%s,%d,%08x\n",
7163  debugstr_wn(pbstrLeft, SysStringLen(pbstrLeft)),
7164  debugstr_wn(pbstrRight, SysStringLen(pbstrRight)), lcid, dwFlags);
7165 
7166  if (!pbstrLeft || !*pbstrLeft)
7167  {
7168  if (pbstrRight && *pbstrRight)
7169  return VARCMP_LT;
7170  }
7171  else if (!pbstrRight || !*pbstrRight)
7172  return VARCMP_GT;
7173 
7174  if (lcid == 0)
7175  {
7176  unsigned int lenLeft = SysStringByteLen(pbstrLeft);
7177  unsigned int lenRight = SysStringByteLen(pbstrRight);
7178  ret = memcmp(pbstrLeft, pbstrRight, min(lenLeft, lenRight));
7179  if (ret < 0)
7180  return VARCMP_LT;
7181  if (ret > 0)
7182  return VARCMP_GT;
7183  if (lenLeft < lenRight)
7184  return VARCMP_LT;
7185  if (lenLeft > lenRight)
7186  return VARCMP_GT;
7187  return VARCMP_EQ;
7188  }
7189  else
7190  {
7191  unsigned int lenLeft = SysStringLen(pbstrLeft);
7192  unsigned int lenRight = SysStringLen(pbstrRight);
7193 
7194  if (lenLeft == 0 || lenRight == 0)
7195  {
7196  if (lenLeft == 0 && lenRight == 0) return VARCMP_EQ;
7197  return lenLeft < lenRight ? VARCMP_LT : VARCMP_GT;
7198  }
7199 
7200  hres = CompareStringW(lcid, dwFlags, pbstrLeft, lenLeft,
7201  pbstrRight, lenRight) - CSTR_LESS_THAN;
7202  TRACE("%d\n", hres);
7203  return hres;
7204  }
7205 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define VARCMP_LT
Definition: oleauto.h:657
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:218
#define VARCMP_EQ
Definition: oleauto.h:658
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:199
#define debugstr_wn
Definition: kernel32.h:33
#define VARCMP_GT
Definition: oleauto.h:659
#define CSTR_LESS_THAN
Definition: winnls.h:452
#define min(a, b)
Definition: monoChain.cc:55

Referenced by START_TEST(), and VarCmp().

◆ VarBstrFromBool()

HRESULT WINAPI VarBstrFromBool ( VARIANT_BOOL  boolIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6851 of file vartype.c.

6852 {
6853  WCHAR szBuff[64];
6854  DWORD dwResId = IDS_TRUE;
6855  LANGID langId;
6856 
6857  TRACE("%d,0x%08x,0x%08x,%p\n", boolIn, lcid, dwFlags, pbstrOut);
6858 
6859  if (!pbstrOut)
6860  return E_INVALIDARG;
6861 
6862  /* VAR_BOOLONOFF and VAR_BOOLYESNO are internal flags used
6863  * for variant formatting */
6865  {
6866  case VAR_BOOLONOFF:
6867  dwResId = IDS_ON;
6868  break;
6869  case VAR_BOOLYESNO:
6870  dwResId = IDS_YES;
6871  break;
6872  case VAR_LOCALBOOL:
6873  break;
6874  default:
6876  }
6877 
6878  lcid = ConvertDefaultLocale(lcid);
6879  langId = LANGIDFROMLCID(lcid);
6880  if (PRIMARYLANGID(langId) == LANG_NEUTRAL)
6882 
6883  if (boolIn == VARIANT_FALSE)
6884  dwResId++; /* Use negative form */
6885 
6886 VarBstrFromBool_GetLocalised:
6887  if (VARIANT_GetLocalisedText(langId, dwResId, szBuff))
6888  {
6889  *pbstrOut = SysAllocString(szBuff);
6890  return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6891  }
6892 
6893  if (langId != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT))
6894  {
6896  goto VarBstrFromBool_GetLocalised;
6897  }
6898 
6899  /* Should never get here */
6900  WARN("Failed to load bool text!\n");
6901  return E_OUTOFMEMORY;
6902 }
#define MAKELCID(lgid, srtid)
#define LANG_NEUTRAL
Definition: nls.h:22
static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest)
Definition: vartype.c:6059
#define WARN(fmt,...)
Definition: debug.h:111
#define SUBLANG_DEFAULT
Definition: nls.h:168
WORD LANGID
Definition: typedefs.h:79
#define IDS_YES
Definition: resource.h:16
#define IDS_TRUE
Definition: resource.h:26
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: lang.c:1502
#define IDS_ON
Definition: resource.h:30
#define E_INVALIDARG
Definition: ddrawi.h:101
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SORT_DEFAULT
#define VAR_BOOLYESNO
Definition: variant.h:103
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LANG_ENGLISH
Definition: nls.h:52
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define VAR_LOCALBOOL
Definition: oleauto.h:330
#define S_OK
Definition: intsafe.h:59
#define VAR_BOOLONOFF
Definition: variant.h:102
#define MAKELANGID(p, s)
Definition: nls.h:15
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by init(), VARIANT_Coerce(), and VARIANT_FormatNumber().

◆ VarBstrFromCy()

HRESULT WINAPI VarBstrFromCy ( CY  cyIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6607 of file vartype.c.

6608 {
6609  WCHAR buff[256];
6610  VARIANT_DI decVal;
6611 
6612  if (!pbstrOut)
6613  return E_INVALIDARG;
6614 
6615  decVal.scale = 4;
6616  decVal.sign = 0;
6617  decVal.bitsnum[0] = cyIn.s.Lo;
6618  decVal.bitsnum[1] = cyIn.s.Hi;
6619  if (cyIn.s.Hi & 0x80000000UL) {
6620  DWORD one = 1;
6621 
6622  /* Negative number! */
6623  decVal.sign = 1;
6624  decVal.bitsnum[0] = ~decVal.bitsnum[0];
6625  decVal.bitsnum[1] = ~decVal.bitsnum[1];
6626  VARIANT_int_add(decVal.bitsnum, 3, &one, 1);
6627  }
6628  decVal.bitsnum[2] = 0;
6630 
6631  if (dwFlags & LOCALE_USE_NLS)
6632  {
6633  WCHAR cybuff[256];
6634 
6635  /* Format the currency for the locale */
6636  cybuff[0] = '\0';
6638  buff, NULL, cybuff, ARRAY_SIZE(cybuff));
6639  *pbstrOut = SysAllocString(cybuff);
6640  }
6641  else
6642  *pbstrOut = VARIANT_BstrReplaceDecimal(buff,lcid,dwFlags);
6643 
6644  return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6645 }
#define LOCALE_USE_NLS
Definition: oleauto.h:338
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1564
static double one
Definition: j0_y0.c:80
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
unsigned int sign
Definition: vartype.c:4155
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char scale
Definition: vartype.c:4154
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
DWORD bitsnum[3]
Definition: vartype.c:4153
static BSTR VARIANT_BstrReplaceDecimal(const WCHAR *buff, LCID lcid, ULONG dwFlags)
Definition: vartype.c:6456
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
ULONG Lo
Definition: compat.h:1910
static unsigned char buff[32768]
Definition: fatten.c:17
static BOOL VARIANT_DI_tostringW(const VARIANT_DI *a, WCHAR *s, unsigned int n)
Definition: vartype.c:4824
static unsigned char VARIANT_int_add(DWORD *v, unsigned int nv, const DWORD *p, unsigned int np)
Definition: vartype.c:4931
LONG Hi
Definition: compat.h:1911

Referenced by _BSTR_CY(), and VARIANT_Coerce().

◆ VarBstrFromDate()

HRESULT WINAPI VarBstrFromDate ( DATE  dateIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6777 of file vartype.c.

6778 {
6779  SYSTEMTIME st;
6781  WCHAR date[128], fmt_buff[80], *time;
6782 
6783  TRACE("(%g,0x%08x,0x%08x,%p)\n", dateIn, lcid, dwFlags, pbstrOut);
6784 
6785  if (!pbstrOut || !VariantTimeToSystemTime(dateIn, &st))
6786  return E_INVALIDARG;
6787 
6788  *pbstrOut = NULL;
6789 
6790  if (dwFlags & VAR_CALENDAR_THAI)
6791  st.wYear += 553; /* Use the Thai buddhist calendar year */
6793  FIXME("VAR_CALENDAR_HIJRI/VAR_CALENDAR_GREGORIAN not handled\n");
6794 
6795  if (dwFlags & LOCALE_USE_NLS)
6797  else
6798  {
6799  double whole = dateIn < 0 ? ceil(dateIn) : floor(dateIn);
6800  double partial = dateIn - whole;
6801 
6802  if (whole == 0.0)
6804  else if (partial > -1e-12 && partial < 1e-12)
6806  }
6807 
6808  if (dwFlags & VAR_TIMEVALUEONLY)
6809  date[0] = '\0';
6810  else
6811  if (!GetLocaleInfoW(lcid, LOCALE_SSHORTDATE, fmt_buff, ARRAY_SIZE(fmt_buff)) ||
6812  !get_date_format(lcid, dwFlags, &st, fmt_buff, date, ARRAY_SIZE(date)))
6813  return E_INVALIDARG;
6814 
6815  if (!(dwFlags & VAR_DATEVALUEONLY))
6816  {
6817  time = date + strlenW(date);
6818  if (time != date)
6819  *time++ = ' ';
6820  if (!GetTimeFormatW(lcid, dwFormatFlags, &st, NULL, time, ARRAY_SIZE(date)-(time-date)))
6821  return E_INVALIDARG;
6822  }
6823 
6824  *pbstrOut = SysAllocString(date);
6825  if (*pbstrOut)
6826  TRACE("returning %s\n", debugstr_w(*pbstrOut));
6827  return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6828 }
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
DWORD dwFormatFlags
Definition: trayclock.cpp:31
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define VAR_CALENDAR_HIJRI
Definition: oleauto.h:329
#define LOCALE_USE_NLS
Definition: oleauto.h:338
BOOL get_date_format(LCID lcid, DWORD flags, const SYSTEMTIME *st, const WCHAR *fmt, WCHAR *date, int date_len)
Definition: vartype.c:6667
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
__u16 time
Definition: mkdosfs.c:366
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
WORD wYear
Definition: winbase.h:877
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define VAR_CALENDAR_THAI
Definition: oleauto.h:333
#define e
Definition: ke_i.h:82
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
Definition: variant.c:1320
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define LOCALE_SSHORTDATE
Definition: winnls.h:60
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
__u16 date
Definition: mkdosfs.c:366
#define VAR_CALENDAR_GREGORIAN
Definition: oleauto.h:334
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079

Referenced by _BSTR_DATE(), VARIANT_Coerce(), and VARIANT_FormatDate().

◆ VarBstrFromDec()

HRESULT WINAPI VarBstrFromDec ( DECIMAL pDecIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6990 of file vartype.c.

6991 {
6992  WCHAR buff[256];
6993  VARIANT_DI temp;
6994 
6995  if (!pbstrOut)
6996  return E_INVALIDARG;
6997 
6998  VARIANT_DIFromDec(pDecIn, &temp);
6999  VARIANT_DI_tostringW(&temp, buff, 256);
7000 
7001  if (dwFlags & LOCALE_USE_NLS)
7002  {
7003  WCHAR numbuff[256];
7004 
7005  /* Format the number for the locale */
7006  numbuff[0] = '\0';
7008  buff, NULL, numbuff, ARRAY_SIZE(numbuff));
7009  TRACE("created NLS string %s\n", debugstr_w(numbuff));
7010  *pbstrOut = SysAllocString(numbuff);
7011  }
7012  else
7013  {
7014  *pbstrOut = VARIANT_BstrReplaceDecimal(buff, lcid, dwFlags);
7015  }
7016 
7017  TRACE("returning %s\n", debugstr_w(*pbstrOut));
7018  return *pbstrOut ? S_OK : E_OUTOFMEMORY;
7019 }
#define LOCALE_USE_NLS
Definition: oleauto.h:338
static void VARIANT_DIFromDec(const DECIMAL *from, VARIANT_DI *to)
Definition: vartype.c:4660
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static BSTR VARIANT_BstrReplaceDecimal(const WCHAR *buff, LCID lcid, ULONG dwFlags)
Definition: vartype.c:6456
#define S_OK
Definition: intsafe.h:59
static calc_node_t temp
Definition: rpn_ieee.c:38
#define ARRAY_SIZE(a)
Definition: main.h:24
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198
static unsigned char buff[32768]
Definition: fatten.c:17
static BOOL VARIANT_DI_tostringW(const VARIANT_DI *a, WCHAR *s, unsigned int n)
Definition: vartype.c:4824

Referenced by _BSTR_DEC(), and VARIANT_Coerce().

◆ VarBstrFromDisp()

HRESULT WINAPI VarBstrFromDisp ( IDispatch pdispIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7086 of file vartype.c.

7087 {
7088  return VARIANT_FromDisp(pdispIn, lcid, pbstrOut, VT_BSTR, dwFlags);
7089 }
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:114

Referenced by VARIANT_Coerce().

◆ VarBstrFromI1()

HRESULT WINAPI VarBstrFromI1 ( signed char  cIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6920 of file vartype.c.

6921 {
6922  ULONG64 ul64 = cIn;
6923 
6924  if (cIn < 0)
6925  {
6926  ul64 = -cIn;
6927  dwFlags |= VAR_NEGATIVE;
6928  }
6929  return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6930 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
unsigned __int64 ULONG64
Definition: imports.h:198
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define VAR_NEGATIVE
Definition: variant.h:104

Referenced by VARIANT_Coerce().

◆ VarBstrFromI2()

HRESULT WINAPI VarBstrFromI2 ( short  sIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6416 of file vartype.c.

6417 {
6418  ULONG64 ul64 = sIn;
6419 
6420  if (sIn < 0)
6421  {
6422  ul64 = -sIn;
6423  dwFlags |= VAR_NEGATIVE;
6424  }
6425  return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6426 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
unsigned __int64 ULONG64
Definition: imports.h:198
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define VAR_NEGATIVE
Definition: variant.h:104

Referenced by VARIANT_Coerce().

◆ VarBstrFromI4()

HRESULT WINAPI VarBstrFromI4 ( LONG  lIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6444 of file vartype.c.

6445 {
6446  ULONG64 ul64 = lIn;
6447 
6448  if (lIn < 0)
6449  {
6450  ul64 = -(LONG64)lIn;
6451  dwFlags |= VAR_NEGATIVE;
6452  }
6453  return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6454 }
int64_t LONG64
Definition: typedefs.h:66
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
unsigned __int64 ULONG64
Definition: imports.h:198
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define VAR_NEGATIVE
Definition: variant.h:104

Referenced by test_VarBstrFromI4(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromI8()

HRESULT WINAPI VarBstrFromI8 ( LONG64  llIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7037 of file vartype.c.

7038 {
7039  ULONG64 ul64 = llIn;
7040 
7041  if (llIn < 0)
7042  {
7043  ul64 = -llIn;
7044  dwFlags |= VAR_NEGATIVE;
7045  }
7046  return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
7047 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
unsigned __int64 ULONG64
Definition: imports.h:198
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define VAR_NEGATIVE
Definition: variant.h:104

Referenced by VARIANT_Coerce().

◆ VarBstrFromR4()

HRESULT WINAPI VarBstrFromR4 ( FLOAT  fltIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6565 of file vartype.c.

6566 {
6567  return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, szFloatFormatW);
6568 }
static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut, LPCWSTR lpszFormat)
Definition: vartype.c:6508
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static const WCHAR szFloatFormatW[]
Definition: vartype.c:42

Referenced by test_VarBstrFromR4(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromR8()

HRESULT WINAPI VarBstrFromR8 ( double  dblIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6586 of file vartype.c.

6587 {
6588  return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, szDoubleFormatW);
6589 }
static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut, LPCWSTR lpszFormat)
Definition: vartype.c:6508
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static const WCHAR szDoubleFormatW[]
Definition: vartype.c:43

Referenced by Global_InvokeEx(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromUI1()

HRESULT WINAPI VarBstrFromUI1 ( BYTE  bIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6395 of file vartype.c.

6396 {
6397  return VARIANT_BstrFromUInt(bIn, lcid, dwFlags, pbstrOut);
6398 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI2()

HRESULT WINAPI VarBstrFromUI2 ( USHORT  usIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6948 of file vartype.c.

6949 {
6950  return VARIANT_BstrFromUInt(usIn, lcid, dwFlags, pbstrOut);
6951 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI4()

HRESULT WINAPI VarBstrFromUI4 ( ULONG  ulIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6969 of file vartype.c.

6970 {
6971  return VARIANT_BstrFromUInt(ulIn, lcid, dwFlags, pbstrOut);
6972 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI8()

HRESULT WINAPI VarBstrFromUI8 ( ULONG64  ullIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7065 of file vartype.c.

7066 {
7067  return VARIANT_BstrFromUInt(ullIn, lcid, dwFlags, pbstrOut);
7068 }
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6363
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by VARIANT_Coerce().

◆ VarCyAbs()

HRESULT WINAPI VarCyAbs ( CY  cyIn,
CY pCyOut 
)

Definition at line 3875 of file vartype.c.

3876 {
3877  if (cyIn.s.Hi == (int)0x80000000 && !cyIn.s.Lo)
3878  return DISP_E_OVERFLOW;
3879 
3880  pCyOut->int64 = cyIn.int64 < 0 ? -cyIn.int64 : cyIn.int64;
3881  return S_OK;
3882 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
ULONG Lo
Definition: compat.h:1910
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
LONG Hi
Definition: compat.h:1911

Referenced by test_VarCyAbs(), and VarAbs().

◆ VarCyAdd()

HRESULT WINAPI VarCyAdd ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3784 of file vartype.c.

3785 {
3786  double l,r;
3787  _VarR8FromCy(cyLeft, &l);
3788  _VarR8FromCy(cyRight, &r);
3789  l = l + r;
3790  return VarCyFromR8(l, pCyOut);
3791 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
r l[0]
Definition: byte_order.h:167

Referenced by test_VarCyAdd(), and VarAdd().

◆ VarCyCmp()

HRESULT WINAPI VarCyCmp ( CY  cyLeft,
CY  cyRight 
)

Definition at line 4011 of file vartype.c.

4012 {
4013  HRESULT hRet;
4014  CY result;
4015 
4016  /* Subtract right from left, and compare the result to 0 */
4017  hRet = VarCySub(cyLeft, cyRight, &result);
4018 
4019  if (SUCCEEDED(hRet))
4020  {
4021  if (result.int64 < 0)
4022  hRet = (HRESULT)VARCMP_LT;
4023  else if (result.int64 > 0)
4024  hRet = (HRESULT)VARCMP_GT;
4025  else
4026  hRet = (HRESULT)VARCMP_EQ;
4027  }
4028  return hRet;
4029 }
#define HRESULT
Definition: msvc.h:9
#define VARCMP_LT
Definition: oleauto.h:657
#define VARCMP_EQ
Definition: oleauto.h:658
Definition: compat.h:1904
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI VarCySub(CY cyLeft, CY cyRight, CY *pCyOut)
Definition: vartype.c:3853
#define VARCMP_GT
Definition: oleauto.h:659
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by VarCmp(), and VarCyCmpR8().

◆ VarCyCmpR8()

HRESULT WINAPI VarCyCmpR8 ( CY  cyLeft,
double  dblRight 
)

Definition at line 4045 of file vartype.c.

4046 {
4047  HRESULT hRet;
4048  CY cyRight;
4049 
4050  hRet = VarCyFromR8(dblRight, &cyRight);
4051 
4052  if (SUCCEEDED(hRet))
4053  hRet = VarCyCmp(cyLeft, cyRight);
4054 
4055  return hRet;
4056 }
Definition: compat.h:1904
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI VarCyCmp(CY cyLeft, CY cyRight)
Definition: vartype.c:4011
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ VarCyFix()

HRESULT WINAPI VarCyFix ( CY  cyIn,
CY pCyOut 
)

Definition at line 3901 of file vartype.c.

3902 {
3903  pCyOut->int64 = cyIn.int64 / CY_MULTIPLIER;
3904  pCyOut->int64 *= CY_MULTIPLIER;
3905  return S_OK;
3906 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by VarFix().

◆ VarCyFromBool()

HRESULT WINAPI VarCyFromBool ( VARIANT_BOOL  boolIn,
CY pCyOut 
)

Definition at line 3619 of file vartype.c.

3620 {
3621  pCyOut->int64 = (LONG64)boolIn * CY_MULTIPLIER;
3622  return S_OK;
3623 }
int64_t LONG64
Definition: typedefs.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromBool(), and VARIANT_Coerce().

◆ VarCyFromDate()

HRESULT WINAPI VarCyFromDate ( DATE  dateIn,
CY pCyOut 
)

Definition at line 3552 of file vartype.c.

3553 {
3554  return VarCyFromR8(dateIn, pCyOut);
3555 }
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502

Referenced by test_VarCyFromDate(), and VARIANT_Coerce().

◆ VarCyFromDec()

HRESULT WINAPI VarCyFromDec ( DECIMAL pdecIn,
CY pCyOut 
)

Definition at line 3703 of file vartype.c.

3704 {
3705  DECIMAL rounded;
3706  HRESULT hRet;
3707 
3708  hRet = VarDecRound(pdecIn, 4, &rounded);
3709 
3710  if (SUCCEEDED(hRet))
3711  {
3712  double d;
3713 
3714  if (DEC_HI32(&rounded))
3715  return DISP_E_OVERFLOW;
3716 
3717  /* Note: Without the casts this promotes to int64 which loses precision */
3718  d = (double)DEC_LO64(&rounded) / (double)CY_Divisors[DEC_SCALE(&rounded)];
3719  if (DEC_SIGN(&rounded))
3720  d = -d;
3721  return VarCyFromR8(d, pCyOut);
3722  }
3723  return hRet;
3724 }
HRESULT WINAPI VarDecRound(const DECIMAL *pDecIn, int cDecimals, DECIMAL *pDecOut)
Definition: vartype.c:5814
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define DEC_SIGN(d)
Definition: variant.h:91
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
#define DEC_HI32(d)
Definition: variant.h:94
static const int CY_Divisors[5]
Definition: vartype.c:3401
#define DEC_LO64(d)
Definition: variant.h:97
#define DEC_SCALE(d)
Definition: variant.h:92
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_VarCyFromDec(), and VARIANT_Coerce().

◆ VarCyFromDisp()

HRESULT WINAPI VarCyFromDisp ( IDispatch pdispIn,
LCID  lcid,
CY pCyOut 
)

Definition at line 3595 of file vartype.c.

3596 {
3597  return VARIANT_FromDisp(pdispIn, lcid, pCyOut, VT_CY, 0);
3598 }
Definition: compat.h:1950
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:114

Referenced by VARIANT_Coerce().

◆ VarCyFromI1()

HRESULT WINAPI VarCyFromI1 ( signed char  cIn,
CY pCyOut 
)

Definition at line 3640 of file vartype.c.

3641 {
3642  pCyOut->int64 = (LONG64)cIn * CY_MULTIPLIER;
3643  return S_OK;
3644 }
int64_t LONG64
Definition: typedefs.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromI1(), and VARIANT_Coerce().

◆ VarCyFromI2()

HRESULT WINAPI VarCyFromI2 ( SHORT  sIn,
CY pCyOut 
)

Definition at line 3440 of file vartype.c.

3441 {
3442  pCyOut->int64 = (LONG64)sIn * CY_MULTIPLIER;
3443  return S_OK;
3444 }
int64_t LONG64
Definition: typedefs.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromI2(), and VARIANT_Coerce().

◆ VarCyFromI4()

HRESULT WINAPI VarCyFromI4 ( LONG  lIn,
CY pCyOut 
)

Definition at line 3461 of file vartype.c.

3462 {
3463  pCyOut->int64 = (LONG64)lIn * CY_MULTIPLIER;
3464  return S_OK;
3465 }
int64_t LONG64
Definition: typedefs.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarAdd(), test_VarCyFromI4(), test_VarDiv(), test_VarIdiv(), test_VarImp(), test_VarMul(), test_VarPow(), test_VarSub(), and VARIANT_Coerce().

◆ VarCyFromI8()

HRESULT WINAPI VarCyFromI8 ( LONG64  llIn,
CY pCyOut 
)

Definition at line 3741 of file vartype.c.

3742 {
3743  if (llIn <= (I8_MIN/CY_MULTIPLIER) || llIn >= (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW;
3744  pCyOut->int64 = llIn * CY_MULTIPLIER;
3745  return S_OK;
3746 }
#define I8_MIN
Definition: variant.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37
#define I8_MAX
Definition: variant.h:65
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Referenced by test_VarCyFromI8(), and VARIANT_Coerce().

◆ VarCyFromR4()

HRESULT WINAPI VarCyFromR4 ( FLOAT  fltIn,
CY pCyOut 
)

Definition at line 3482 of file vartype.c.

3483 {
3484  return VarCyFromR8(fltIn, pCyOut);
3485 }
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502

Referenced by test_VarCyFromR4(), and VARIANT_Coerce().

◆ VarCyFromR8()

HRESULT WINAPI VarCyFromR8 ( double  dblIn,
CY pCyOut 
)

Definition at line 3502 of file vartype.c.

3503 {
3504 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
3505  /* This code gives identical results to Win32 on Intel.
3506  * Here we use fp exceptions to catch overflows when storing the value.
3507  */
3508  static const unsigned short r8_fpcontrol = 0x137f;
3509  static const double r8_multiplier = CY_MULTIPLIER_F;
3510  unsigned short old_fpcontrol, result_fpstatus;
3511 
3512  /* Clear exceptions, save the old fp state and load the new state */
3513  __asm__ __volatile__( "fnclex" );
3514  __asm__ __volatile__( "fstcw %0" : "=m" (old_fpcontrol) : );
3515  __asm__ __volatile__( "fldcw %0" : : "m" (r8_fpcontrol) );
3516  /* Perform the conversion. */
3517  __asm__ __volatile__( "fldl %0" : : "m" (dblIn) );
3518  __asm__ __volatile__( "fmull %0" : : "m" (r8_multiplier) );
3519  __asm__ __volatile__( "fistpll %0" : : "m" (*pCyOut) );
3520  /* Save the resulting fp state, load the old state and clear exceptions */
3521  __asm__ __volatile__( "fstsw %0" : "=m" (result_fpstatus) : );
3522  __asm__ __volatile__( "fnclex" );
3523  __asm__ __volatile__( "fldcw %0" : : "m" (old_fpcontrol) );
3524 
3525  if (result_fpstatus & 0x9) /* Overflow | Invalid */
3526  return DISP_E_OVERFLOW;
3527 #else
3528  /* This version produces slightly different results for boundary cases */
3529  if (dblIn < -922337203685477.5807 || dblIn >= 922337203685477.5807)
3530  return DISP_E_OVERFLOW;
3531  dblIn *= CY_MULTIPLIER_F;
3532  VARIANT_DutchRound(LONG64, dblIn, pCyOut->int64);
3533 #endif
3534  return S_OK;
3535 }
#define CY_MULTIPLIER_F
Definition: vartype.c:38
__asm__("\t.globl GetPhys\n" "GetPhys:\t\n" "mflr 0\n\t" "stwu 0,-16(1)\n\t" "mfmsr 5\n\t" "andi. 6,5,0xffef\n\t" "mtmsr 6\n\t" "isync\n\t" "sync\n\t" "lwz 3,0(3)\n\t" "mtmsr 5\n\t" "isync\n\t" "sync\n\t" "lwz 0,0(1)\n\t" "addi 1,1,16\n\t" "mtlr 0\n\t" "blr")
#define VARIANT_DutchRound(typ, value, res)
Definition: vartype.c:76
int64_t LONG64
Definition: typedefs.h:66
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Referenced by test_VarCyFromDate(), test_VarCyFromR8(), VarCyAdd(), VarCyCmpR8(), VarCyFromDate(), VarCyFromDec(), VarCyFromR4(), VarCyMul(), VarCyMulI4(), VarCyMulI8(), VarCySub(), VARIANT_Coerce(), and VarNumFromParseNum().

◆ VarCyFromStr()

HRESULT WINAPI VarCyFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
CY pCyOut 
)

Definition at line 3574 of file vartype.c.

3575 {
3576  return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pCyOut, VT_CY);
3577 }
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: compat.h:1950
static HRESULT VARIANT_NumberFromBstr(OLECHAR *pStrIn, LCID lcid, ULONG ulFlags, void *pOut, VARTYPE vt)
Definition: vartype.c:89

Referenced by VARIANT_Coerce().

◆ VarCyFromUI1()

HRESULT WINAPI VarCyFromUI1 ( BYTE  bIn,
CY pCyOut 
)

Definition at line 3419 of file vartype.c.

3420 {
3421  pCyOut->int64 = (ULONG64)bIn * CY_MULTIPLIER;
3422  return S_OK;
3423 }
LONGLONG int64
Definition: compat.h:1914
unsigned __int64 ULONG64
Definition: imports.h:198
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromUI1(), and VARIANT_Coerce().

◆ VarCyFromUI2()

HRESULT WINAPI VarCyFromUI2 ( USHORT  usIn,
CY pCyOut 
)

Definition at line 3661 of file vartype.c.

3662 {
3663  pCyOut->int64 = (ULONG64)usIn * CY_MULTIPLIER;
3664  return S_OK;
3665 }
LONGLONG int64
Definition: compat.h:1914
unsigned __int64 ULONG64
Definition: imports.h:198
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromUI2(), and VARIANT_Coerce().

◆ VarCyFromUI4()

HRESULT WINAPI VarCyFromUI4 ( ULONG  ulIn,
CY pCyOut 
)

Definition at line 3682 of file vartype.c.

3683 {
3684  pCyOut->int64 = (ULONG64)ulIn * CY_MULTIPLIER;
3685  return S_OK;
3686 }
LONGLONG int64
Definition: compat.h:1914
unsigned __int64 ULONG64
Definition: imports.h:198
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by test_VarCyFromUI4(), and VARIANT_Coerce().

◆ VarCyFromUI8()

HRESULT WINAPI VarCyFromUI8 ( ULONG64  ullIn,
CY pCyOut 
)

Definition at line 3763 of file vartype.c.

3764 {
3765  if (ullIn > (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW;
3766  pCyOut->int64 = ullIn * CY_MULTIPLIER;
3767  return S_OK;
3768 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37
#define I8_MAX
Definition: variant.h:65
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Referenced by test_VarCyFromUI8(), and VARIANT_Coerce().

◆ VarCyInt()

HRESULT WINAPI VarCyInt ( CY  cyIn,
CY pCyOut 
)

Definition at line 3925 of file vartype.c.

3926 {
3927  pCyOut->int64 = cyIn.int64 / CY_MULTIPLIER;
3928  pCyOut->int64 *= CY_MULTIPLIER;
3929 
3930  if (cyIn.int64 < 0 && cyIn.int64 % CY_MULTIPLIER != 0)
3931  {
3932  pCyOut->int64 -= CY_MULTIPLIER;
3933  }
3934  return S_OK;
3935 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
#define CY_MULTIPLIER
Definition: vartype.c:37

Referenced by VarInt().

◆ VarCyMul()

HRESULT WINAPI VarCyMul ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3807 of file vartype.c.

3808 {
3809  double l,r;
3810  _VarR8FromCy(cyLeft, &l);
3811  _VarR8FromCy(cyRight, &r);
3812  l = l * r;
3813  return VarCyFromR8(l, pCyOut);
3814 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
r l[0]
Definition: byte_order.h:167

Referenced by test_VarCyMul(), and VarMul().

◆ VarCyMulI4()

HRESULT WINAPI VarCyMulI4 ( CY  cyLeft,
LONG  lRight,
CY pCyOut 
)

Definition at line 3830 of file vartype.c.

3831 {
3832  double d;
3833 
3834  _VarR8FromCy(cyLeft, &d);
3835  d = d * lRight;
3836  return VarCyFromR8(d, pCyOut);
3837 }
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
#define d
Definition: ke_i.h:81

◆ VarCyMulI8()

HRESULT WINAPI VarCyMulI8 ( CY  cyLeft,
LONG64  llRight,
CY pCyOut 
)

Definition at line 4072 of file vartype.c.

4073 {
4074  double d;
4075 
4076  _VarR8FromCy(cyLeft, &d);
4077  d = d * (double)llRight;
4078  return VarCyFromR8(d, pCyOut);
4079 }
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define d
Definition: ke_i.h:81

◆ VarCyNeg()

HRESULT WINAPI VarCyNeg ( CY  cyIn,
CY pCyOut 
)

Definition at line 3950 of file vartype.c.

3951 {
3952  if (cyIn.s.Hi == (int)0x80000000 && !cyIn.s.Lo)
3953  return DISP_E_OVERFLOW;
3954 
3955  pCyOut->int64 = -cyIn.int64;
3956  return S_OK;
3957 }
LONGLONG int64
Definition: compat.h:1914
#define S_OK
Definition: intsafe.h:59
ULONG Lo
Definition: compat.h:1910
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
LONG Hi
Definition: compat.h:1911

Referenced by test_VarCyNeg(), and VarNeg().

◆ VarCyRound()

HRESULT WINAPI VarCyRound ( CY  cyIn,
int  cDecimals,
CY pCyOut 
)

Definition at line 3973 of file vartype.c.

3974 {
3975  if (cDecimals < 0)
3976  return E_INVALIDARG;
3977 
3978  if (cDecimals > 3)
3979  {
3980  /* Rounding to more precision than we have */
3981  *pCyOut = cyIn;
3982  return S_OK;
3983  }
3984  else
3985  {
3986  double d, div = CY_Divisors[cDecimals];
3987 
3988  _VarR8FromCy(cyIn, &d);
3989  d = d * div;
3990  VARIANT_DutchRound(LONGLONG, d, pCyOut->int64);
3991  d = (double)pCyOut->int64 / div * CY_MULTIPLIER_F;
3992  VARIANT_DutchRound(LONGLONG, d, pCyOut->int64);
3993  return S_OK;
3994  }
3995 }
#define CY_MULTIPLIER_F
Definition: vartype.c:38
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define E_INVALIDARG
Definition: ddrawi.h:101
#define VARIANT_DutchRound(typ, value, res)
Definition: vartype.c:76
int64_t LONGLONG
Definition: typedefs.h:66
#define d
Definition: ke_i.h:81
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
LONGLONG int64
Definition: compat.h:1914
static const int CY_Divisors[5]
Definition: vartype.c:3401
#define S_OK
Definition: intsafe.h:59

◆ VarCySub()

HRESULT WINAPI VarCySub ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3853 of file vartype.c.

3854 {
3855  double l,r;
3856  _VarR8FromCy(cyLeft, &l);
3857  _VarR8FromCy(cyRight, &r);
3858  l = l - r;
3859  return VarCyFromR8(l, pCyOut);
3860 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:254
r l[0]
Definition: byte_order.h:167

Referenced by test_VarCySub(), VarCyCmp(), and VarSub().

◆ VarDateFromBool()

HRESULT WINAPI VarDateFromBool ( VARIANT_BOOL  boolIn,
DATE pdateOut 
)

Definition at line 7331 of file vartype.c.

7332 {
7333  return VarR8FromBool(boolIn, pdateOut);
7334 }
HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double *pDblOut)
Definition: vartype.c:3188

Referenced by test_VarDateFromBool(), and VARIANT_Coerce().

◆ VarDateFromCy()

HRESULT WINAPI VarDateFromCy ( CY  cyIn,
DATE pdateOut 
)

Definition at line 7348 of file vartype.c.

7349 {
7350  return VarR8FromCy(cyIn, pdateOut);
7351 }
HRESULT WINAPI VarR8FromCy(CY cyIn, double *pDblOut)
Definition: vartype.c:3112

Referenced by test_VarDateFromCy(), and VARIANT_Coerce().

◆ VarDateFromDec()

HRESULT WINAPI VarDateFromDec ( DECIMAL pdecIn,
DATE pdateOut 
)

Definition at line 8004 of file vartype.c.

8005 {
8006  return VarR8FromDec(pdecIn, pdateOut);
8007 }
HRESULT WINAPI VarR8FromDec(const DECIMAL *pDecIn, double *pDblOut)
Definition: vartype.c:3266

Referenced by test_VarDateFromDec(), and VARIANT_Coerce().

◆ VarDateFromDisp()

HRESULT WINAPI VarDateFromDisp ( IDispatch pdispIn,
LCID  lcid,
DATE pdateOut 
)

Definition at line 7314 of file vartype.c.

7315 {
7316  return VARIANT_FromDisp(pdispIn, lcid, pdateOut, VT_DATE, 0);
7317 }
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:114

Referenced by VARIANT_Coerce().

◆ VarDateFromI1()

HRESULT WINAPI VarDateFromI1 ( signed char  cIn,
DATE pdateOut 
)

Definition at line 7953 of file vartype.c.

7954 {
7955  return VarR8FromI1(cIn, pdateOut);
7956 }
HRESULT WINAPI VarR8FromI1(signed char cIn, double *pDblOut)
Definition: vartype.c:3208

Referenced by test_VarDateFromI1(), and VARIANT_Coerce().

◆ VarDateFromI2()

HRESULT WINAPI VarDateFromI2 ( short  sIn,
DATE pdateOut 
)

Definition at line 7240 of file vartype.c.

7241 {
7242  return VarR8FromI2(sIn, pdateOut);
7243 }
HRESULT WINAPI VarR8FromI2(SHORT sIn, double *pDblOut)
Definition: vartype.c:3061

Referenced by test_VarDateFromI2(), and VARIANT_Coerce().

◆ VarDateFromI4()

HRESULT WINAPI VarDateFromI4 ( LONG  lIn,
DATE pdateOut 
)

Definition at line 7257 of file vartype.c.

7258 {
7259  return VarDateFromR8(lIn, pdateOut);
7260 }
HRESULT WINAPI VarDateFromR8(double dblIn, DATE *pdateOut)
Definition: vartype.c:7291

Referenced by test_VarDateFromI4(), and VARIANT_Coerce().

◆ VarDateFromI8()

HRESULT WINAPI VarDateFromI8 ( LONG64  llIn,
DATE pdateOut 
)

Definition at line 8022 of file vartype.c.

8023 {
8024  if (llIn < DATE_MIN || llIn > DATE_MAX) return DISP_E_OVERFLOW;
8025  *pdateOut = (DATE)llIn;
8026  return S_OK;
8027 }
double DATE
Definition: compat.h:1902
#define S_OK
Definition: intsafe.h:59
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
#define DATE_MAX
Definition: vartype.c:89

Referenced by test_VarDateFromI8(), and VARIANT_Coerce().

◆ VarDateFromR4()

HRESULT WINAPI VarDateFromR4 ( FLOAT  fltIn,
DATE pdateOut 
)

Definition at line 7274 of file vartype.c.

7275 {
7276  return VarR8FromR4(fltIn, pdateOut);
7277 }
HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double *pDblOut)
Definition: vartype.c:3095

Referenced by test_VarDateFromR4(), and VARIANT_Coerce().

◆ VarDateFromR8()

HRESULT WINAPI VarDateFromR8 ( double  dblIn,
DATE pdateOut 
)

Definition at line 7291 of file vartype.c.

7292 {
7293  if (dblIn <= (DATE_MIN - 1.0) || dblIn >= (DATE_MAX + 1.0)) return DISP_E_OVERFLOW;
7294  *pdateOut = (DATE)dblIn;
7295  return S_OK;
7296 }
double DATE
Definition: compat.h:1902
#define DATE_MIN
Definition: vartype.c:88
#define S_OK
Definition: intsafe.h:59
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
#define DATE_MAX
Definition: vartype.c:89

Referenced by test_VarDateFromR8(), VarDateFromI4(), VarDateFromUI4(), and VARIANT_Coerce().

◆ VarDateFromStr()

HRESULT WINAPI VarDateFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
DATE pdateOut 
)

Definition at line 7594 of file vartype.c.

7595 {
7596  static const USHORT ParseDateTokens[] =
7597  {
7613  LOCALE_SDATE
7614  };
7615  static const BYTE ParseDateMonths[] =
7616  {
7617  1,2,3,4,5,6,7,8,9,10,11,12,13,
7618  1,2,3,4,5,6,7,8,9,10,11,12,13
7619  };
7620  unsigned int i;
7621  BSTR tokens[ARRAY_SIZE(ParseDateTokens)];
7622  DATEPARSE dp;
7623  DWORD dwDateSeps = 0, iDate = 0;
7624  HRESULT hRet = S_OK;
7625 
7628  return E_INVALIDARG;
7629 
7630  if (!strIn)
7631  return DISP_E_TYPEMISMATCH;
7632 
7633  *pdateOut = 0.0;
7634 
7635  TRACE("(%s,0x%08x,0x%08x,%p)\n", debugstr_w(strIn), lcid, dwFlags, pdateOut);
7636 
7637  memset(&dp, 0, sizeof(dp));
7638 
7639  GetLocaleInfoW(lcid, LOCALE_IDATE|LOCALE_RETURN_NUMBER|(dwFlags & LOCALE_NOUSEROVERRIDE),
7640  (LPWSTR)&iDate, sizeof(iDate)/sizeof(WCHAR));
7641  TRACE("iDate is %d\n", iDate);
7642 
7643  /* Get the month/day/am/pm tokens for this locale */
7644  for (i = 0; i < ARRAY_SIZE(tokens); i++)
7645  {
7646  WCHAR buff[128];
7647  LCTYPE lctype = ParseDateTokens[i] | (dwFlags & LOCALE_NOUSEROVERRIDE);
7648 
7649  /* FIXME: Alternate calendars - should use GetCalendarInfo() and/or
7650  * GetAltMonthNames(). We should really cache these strings too.
7651  */
7652  buff[0] = '\0';
7653  GetLocaleInfoW(lcid, lctype, buff, ARRAY_SIZE(buff));
7654  tokens[i] = SysAllocString(buff);
7655  TRACE("token %d is %s\n", i, debugstr_w(tokens[i]));
7656  }
7657 
7658  /* Parse the string into our structure */
7659  while (*strIn)
7660  {
7661  if (isdigitW(*strIn))
7662  {
7663  if (dp.dwCount >= 6)
7664  {
7665  hRet = DISP_E_TYPEMISMATCH;
7666  break;
7667  }
7668  dp.dwValues[dp.dwCount] = strtoulW(strIn, &strIn, 10);
7669  dp.dwCount++;
7670  strIn--;
7671  }
7672  else if (isalphaW(*strIn))
7673  {
7674  BOOL bFound = FALSE;
7675 
7676  for (i = 0; i < ARRAY_SIZE(tokens); i++)
7677  {
7678  DWORD dwLen = strlenW(tokens[i]);
7679  if (dwLen && !strncmpiW(strIn, tokens[i], dwLen))
7680  {
7681  if (i <= 25)
7682  {
7683  if (dp.dwCount >= 6)
7684  hRet = DISP_E_TYPEMISMATCH;
7685  else
7686  {
7687  dp.dwValues[dp.dwCount] = ParseDateMonths[i];
7688  dp.dwFlags[dp.dwCount] |= (DP_MONTH|DP_DATESEP);
7689  dp.dwCount++;
7690  }
7691  }
7692  else if (i > 39 && i < 42)
7693  {
7694  if (!dp.dwCount || dp.dwParseFlags & (DP_AM|DP_PM))
7695  hRet = DISP_E_TYPEMISMATCH;
7696  else
7697  {
7698  dp.dwFlags[dp.dwCount - 1] |= (i == 40 ? DP_AM : DP_PM);
7699  dp.dwParseFlags |= (i == 40 ? DP_AM : DP_PM);
7700  }
7701  }
7702  strIn += (dwLen - 1);
7703  bFound = TRUE;
7704  break;
7705  }
7706  }
7707 
7708  if (!bFound)
7709  {
7710  if ((*strIn == 'a' || *strIn == 'A' || *strIn == 'p' || *strIn == 'P') &&
7711  (dp.dwCount && !(dp.dwParseFlags & (DP_AM|DP_PM))))
7712  {
7713  /* Special case - 'a' and 'p' are recognised as short for am/pm */
7714  if (*strIn == 'a' || *strIn == 'A')
7715  {
7716  dp.dwFlags[dp.dwCount - 1] |= DP_AM;
7717  dp.dwParseFlags |= DP_AM;
7718  }
7719  else
7720  {
7721  dp.dwFlags[dp.dwCount - 1] |= DP_PM;
7722  dp.dwParseFlags |= DP_PM;
7723  }
7724  strIn++;
7725  }
7726  else
7727  {
7728  TRACE("No matching token for %s\n", debugstr_w(strIn));
7729  hRet = DISP_E_TYPEMISMATCH;
7730  break;
7731  }
7732  }
7733  }
7734  else if (*strIn == ':' || *strIn == '.')
7735  {
7736  if (!dp.dwCount || !strIn[1])
7737  hRet = DISP_E_TYPEMISMATCH;
7738  else
7739  if (tokens[42][0] == *strIn)
7740  {
7741  dwDateSeps++;
7742  if (dwDateSeps > 2)
7743  hRet = DISP_E_TYPEMISMATCH;
7744  else
7745  dp.dwFlags[dp.dwCount - 1] |= DP_DATESEP;
7746  }
7747  else
7748  dp.dwFlags[dp.dwCount - 1] |= DP_TIMESEP;
7749  }
7750  else if (*strIn == '-' || *strIn == '/')
7751  {
7752  dwDateSeps++;
7753  if (dwDateSeps > 2 || !dp.dwCount || !strIn[1])
7754  hRet = DISP_E_TYPEMISMATCH;
7755  else
7756  dp.dwFlags[dp.dwCount - 1] |= DP_DATESEP;
7757  }
7758  else if (*strIn == ',' || isspaceW(*strIn))
7759  {
7760  if (*strIn == ',' && !strIn[1])
7761  hRet = DISP_E_TYPEMISMATCH;
7762  }
7763  else
7764  {
7765  hRet = DISP_E_TYPEMISMATCH;
7766  }
7767  strIn++;
7768  }
7769 
7770  if (!dp.dwCount || dp.dwCount > 6 ||
7771  (dp.dwCount == 1 && !(dp.dwParseFlags & (DP_AM|DP_PM))))
7772  hRet = DISP_E_TYPEMISMATCH;
7773 
7774  if (SUCCEEDED(hRet))
7775  {
7776  SYSTEMTIME st;
7777  DWORD dwOffset = 0; /* Start of date fields in dp.dwValues */
7778 
7779  st.wDayOfWeek = st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0;
7780 
7781  /* Figure out which numbers correspond to which fields.
7782  *
7783  * This switch statement works based on the fact that native interprets any
7784  * fields that are not joined with a time separator ('.' or ':') as date
7785  * fields. Thus we construct a value from 0-32 where each set bit indicates
7786  * a time field. This encapsulates the hundreds of permutations of 2-6 fields.
7787  * For valid permutations, we set dwOffset to point to the first date field
7788  * and shorten dp.dwCount by the number of time fields found. The real
7789  * magic here occurs in VARIANT_MakeDate() above, where we determine what
7790  * each date number must represent in the context of iDate.
7791  */
7792  TRACE("0x%08x\n", TIMEFLAG(0)|TIMEFLAG(1)|TIMEFLAG(2)|TIMEFLAG(3)|TIMEFLAG(4));
7793 
7794  switch (TIMEFLAG(0)|TIMEFLAG(1)|TIMEFLAG(2)|TIMEFLAG(3)|TIMEFLAG(4))
7795  {
7796  case 0x1: /* TT TTDD TTDDD */
7797  if (dp.dwCount > 3 &&
7798  ((dp.dwFlags[2] & (DP_AM|DP_PM)) || (dp.dwFlags[3] & (DP_AM|DP_PM)) ||
7799  (dp.dwFlags[4] & (DP_AM|DP_PM))))
7800  hRet = DISP_E_TYPEMISMATCH;
7801  else if (dp.dwCount != 2 && dp.dwCount != 4 && dp.dwCount != 5)
7802  hRet = DISP_E_TYPEMISMATCH;
7803  st.wHour = dp.dwValues[0];
7804  st.wMinute = dp.dwValues[1];
7805  dp.dwCount -= 2;
7806  dwOffset = 2;
7807  break;
7808 
7809  case 0x3: /* TTT TTTDD TTTDDD */
7810  if (dp.dwCount > 4 &&
7811  ((dp.dwFlags[3] & (DP_AM|DP_PM)) || (dp.dwFlags[4] & (DP_AM|DP_PM)) ||
7812  (dp.dwFlags[5] & (DP_AM|DP_PM))))
7813  hRet = DISP_E_TYPEMISMATCH;
7814  else if (dp.dwCount != 3 && dp.dwCount != 5 && dp.dwCount != 6)
7815  hRet = DISP_E_TYPEMISMATCH;
7816  st.wHour = dp.dwValues[0];
7817  st.wMinute = dp.dwValues[1];
7818  st.wSecond = dp.dwValues[2];
7819  dwOffset = 3;
7820  dp.dwCount -= 3;
7821  break;
7822 
7823  case 0x4: /* DDTT */
7824  if (dp.dwCount != 4 ||
7825  (dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)))
7826  hRet = DISP_E_TYPEMISMATCH;
7827 
7828  st.wHour = dp.dwValues[2];
7829  st.wMinute = dp.dwValues[3];
7830  dp.dwCount -= 2;
7831  break;
7832 
7833  case 0x0: /* T DD DDD TDDD TDDD */
7834  if (dp.dwCount == 1 && (dp.dwParseFlags & (DP_AM|DP_PM)))
7835  {
7836  st.wHour = dp.dwValues[0]; /* T */
7837  dp.dwCount = 0;
7838  break;
7839  }
7840  else if (dp.dwCount > 4 || (dp.dwCount < 3 && dp.dwParseFlags & (DP_AM|DP_PM)))
7841  {
7842  hRet = DISP_E_TYPEMISMATCH;
7843  }
7844  else if (dp.dwCount == 3)
7845  {
7846  if (dp.dwFlags[0] & (DP_AM|DP_PM)) /* TDD */
7847  {
7848  dp.dwCount = 2;
7849  st.wHour = dp.dwValues[0];
7850  dwOffset = 1;
7851  break;
7852  }
7853  if (dp.dwFlags[2] & (DP_AM|DP_PM)) /* DDT */
7854  {
7855  dp.dwCount = 2;
7856  st.wHour = dp.dwValues[2];
7857  break;
7858  }
7859  else if (dp.dwParseFlags & (DP_AM|DP_PM))
7860  hRet = DISP_E_TYPEMISMATCH;
7861  }
7862  else if (dp.dwCount == 4)
7863  {
7864  dp.dwCount = 3;
7865  if (dp.dwFlags[0] & (DP_AM|DP_PM)) /* TDDD */
7866  {
7867  st.wHour = dp.dwValues[0];
7868  dwOffset = 1;
7869  }
7870  else if (dp.dwFlags[3] & (DP_AM|DP_PM)) /* DDDT */
7871  {
7872  st.wHour = dp.dwValues[3];
7873  }
7874  else
7875  hRet = DISP_E_TYPEMISMATCH;
7876  break;
7877  }
7878  /* .. fall through .. */
7879 
7880  case 0x8: /* DDDTT */
7881  if ((dp.dwCount == 2 && (dp.dwParseFlags & (DP_AM|DP_PM))) ||
7882  (dp.dwCount == 5 && ((dp.dwFlags[0] & (DP_AM|DP_PM)) ||
7883  (dp.dwFlags[1] & (DP_AM|DP_PM)) || (dp.dwFlags[2] & (DP_AM|DP_PM)))) ||
7884  dp.dwCount == 4 || dp.dwCount == 6)
7885  hRet = DISP_E_TYPEMISMATCH;
7886  st.wHour = dp.dwValues[3];
7887  st.wMinute = dp.dwValues[4];
7888  if (dp.dwCount == 5)
7889  dp.dwCount -= 2;
7890  break;
7891 
7892  case 0xC: /* DDTTT */
7893  if (dp.dwCount != 5 ||
7894  (dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)))
7895  hRet = DISP_E_TYPEMISMATCH;
7896  st.wHour = dp.dwValues[2];
7897  st.wMinute = dp.dwValues[3];
7898  st.wSecond = dp.dwValues[4];
7899  dp.dwCount -= 3;
7900  break;
7901 
7902  case 0x18: /* DDDTTT */
7903  if ((dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)) ||
7904  (dp.dwFlags[2] & (DP_AM|DP_PM)))
7905  hRet = DISP_E_TYPEMISMATCH;
7906  st.wHour = dp.dwValues[3];
7907  st.wMinute = dp.dwValues[4];
7908  st.wSecond = dp.dwValues[5];
7909  dp.dwCount -= 3;
7910  break;
7911 
7912  default:
7913  hRet = DISP_E_TYPEMISMATCH;
7914  break;
7915  }
7916 
7917  if (SUCCEEDED(hRet))
7918  {
7919  hRet = VARIANT_MakeDate(&dp, iDate, dwOffset, &st);
7920 
7921  if (dwFlags & VAR_TIMEVALUEONLY)
7922  {
7923  st.wYear = 1899;
7924  st.wMonth = 12;
7925  st.wDay = 30;
7926  }
7927  else if (dwFlags & VAR_DATEVALUEONLY)
7928  st.wHour = st.wMinute = st.wSecond = 0;
7929 
7930  /* Finally, convert the value to a VT_DATE */
7931  if (SUCCEEDED(hRet))
7932  hRet = SystemTimeToVariantTime(&st, pdateOut) ? S_OK : DISP_E_TYPEMISMATCH;
7933  }
7934  }
7935 
7936  for (i = 0; i < ARRAY_SIZE(tokens); i++)
7937  SysFreeString(tokens[i]);
7938  return hRet;
7939 }
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define TRUE
Definition: types.h:120
#define DP_TIMESEP
Definition: vartype.c:7354
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
DWORD dwValues[6]
Definition: vartype.c:7365
WORD wMonth
Definition: winbase.h:878
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_IDATE
Definition: winnls.h:63
DWORD dwParseFlags
Definition: vartype.c:7363
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
WORD wDayOfWeek
Definition: winbase.h:879
#define LOCALE_SMONTHNAME13
Definition: winnls.h:103
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
#define DP_MONTH
Definition: vartype.c:7356
OLECHAR * BSTR
Definition: compat.h:1942
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define TIMEFLAG(i)
Definition: vartype.c:7368
WORD wYear
Definition: winbase.h:877
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
DWORD LCTYPE
Definition: winnls.h:514
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define DP_AM
Definition: vartype.c:7357
unsigned int BOOL
Definition: ntddk_ex.h:94
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
WORD wMinute
Definition: winbase.h:882
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SABBREVMONTHNAME13
Definition: winnls.h:116
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SDATE
Definition: winnls.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
DWORD dwCount
Definition: vartype.c:7362
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define DP_DATESEP
Definition: vartype.c:7355
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
WORD wSecond
Definition: winbase.h:883
#define LOCALE_S1159
Definition: winnls.h:71
WORD wMilliseconds
Definition: winbase.h:884
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
WORD wDay
Definition: winbase.h:880
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define S_OK
Definition: intsafe.h:59
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
unsigned short USHORT
Definition: pedump.c:61
#define ARRAY_SIZE(a)
Definition: main.h:24
WORD wHour
Definition: winbase.h:881
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define DP_PM
Definition: vartype.c:7358
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
DWORD dwFlags[6]
Definition: vartype.c:7364
#define strtoulW(s1, s2, b)
Definition: unicode.h:41
WINE_UNICODE_INLINE int isalphaW(WCHAR wc)
Definition: unicode.h:195
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
#define LOCALE_S2359
Definition: winnls.h:72
static unsigned char buff[32768]
Definition: fatten.c:17
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
Definition: variant.c:1289
static HRESULT VARIANT_MakeDate(DATEPARSE *dp, DWORD iDate, DWORD offset, SYSTEMTIME *st)
Definition: vartype.c:7393
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_VarDateFromStr(), and VARIANT_Coerce().

◆ VarDateFromUI1()

HRESULT WINAPI VarDateFromUI1 ( BYTE  bIn,
DATE pdateOut 
)

Definition at line 7223 of file vartype.c.

7224 {
7225  return VarR8FromUI1(bIn, pdateOut);
7226 }
HRESULT WINAPI VarR8FromUI1(BYTE bIn, double *pDblOut)
Definition: vartype.c:3044

Referenced by test_VarDateFromUI1(), and VARIANT_Coerce().

◆ VarDateFromUI2()

HRESULT WINAPI VarDateFromUI2 ( USHORT  uiIn,
DATE pdateOut 
)

Definition at line 7970 of file vartype.c.

7971 {
7972  return VarR8FromUI2(uiIn, pdateOut);
7973 }
HRESULT WINAPI VarR8FromUI2(USHORT usIn, double *pDblOut)
Definition: vartype.c:3228

Referenced by test_VarDateFromUI2(), and VARIANT_Coerce().

◆ VarDateFromUI4()

HRESULT WINAPI VarDateFromUI4 ( ULONG  ulIn,
DATE pdateOut 
)

Definition at line 7987 of file vartype.c.

7988 {
7989  return VarDateFromR8(ulIn, pdateOut);
7990 }
HRESULT WINAPI VarDateFromR8(double dblIn, DATE *pdateOut)
Definition: vartype.c:7291

Referenced by test_VarDateFromUI4(), and VARIANT_Coerce().

◆ VarDateFromUI8()

HRESULT WINAPI VarDateFromUI8 ( ULONG64  ullIn,
DATE pdateOut 
)

Definition at line 8042 of file vartype.c.

8043 {
8044  if (ullIn > DATE_MAX) return DISP_E_OVERFLOW;
8045  *pdateOut = (DATE)ullIn;
8046  return S_OK;
8047 }
double DATE
Definition: compat.h:1902
#define S_OK
Definition: intsafe.h:59
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
#define DATE_MAX
Definition: vartype.c:89

Referenced by test_VarDateFromUI8(), and VARIANT_Coerce().

◆ VarDecAbs()

HRESULT WINAPI VarDecAbs ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5697 of file vartype.c.

5698 {
5699  *pDecOut = *pDecIn;
5700  DEC_SIGN(pDecOut) &= ~DECIMAL_NEG;
5701  return S_OK;
5702 }
#define DEC_SIGN(d)
Definition: variant.h:91
#define S_OK
Definition: intsafe.h:59

Referenced by test_VarDecAbs().

◆ VarDecAdd()

HRESULT WINAPI VarDecAdd ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 4587 of file vartype.c.

4588 {
4589  HRESULT hRet;
4590  DECIMAL scaled[2];
4591 
4592  hRet = VARIANT_DecScale(&pDecLeft, &pDecRight, scaled);
4593 
4594  if (SUCCEEDED(hRet))
4595  {
4596  /* Our decimals now have the same scale, we can add them as 96 bit integers */
4597  ULONG overflow = 0;
4598  BYTE sign = DECIMAL_POS;
4599  int cmp;
4600 
4601  /* Correct for the sign of the result */
4602  if (DEC_SIGN(pDecLeft) && DEC_SIGN(pDecRight))
4603  {
4604  /* -x + -y : Negative */
4605  sign = DECIMAL_NEG;
4606  goto VarDecAdd_AsPositive;
4607  }
4608  else if (DEC_SIGN(pDecLeft) && !DEC_SIGN(pDecRight))
4609  {
4610  cmp = VARIANT_DecCmp(pDecLeft, pDecRight);
4611 
4612  /* -x + y : Negative if x > y */
4613  if (cmp > 0)
4614  {
4615  sign = DECIMAL_NEG;
4616 VarDecAdd_AsNegative:
4617  DEC_LO32(pDecOut) = VARIANT_Sub(DEC_LO32(pDecLeft), DEC_LO32(pDecRight), &overflow);
4618  DEC_MID32(pDecOut) = VARIANT_Sub(DEC_MID32(pDecLeft), DEC_MID32(pDecRight), &overflow);
4619  DEC_HI32(pDecOut) = VARIANT_Sub(DEC_HI32(pDecLeft), DEC_HI32(pDecRight), &overflow);
4620  }
4621  else
4622  {
4623 VarDecAdd_AsInvertedNegative:
4624  DEC_LO32(pDecOut) = VARIANT_Sub(DEC_LO32(pDecRight), DEC_LO32(pDecLeft), &overflow);
4625  DEC_MID32(pDecOut) = VARIANT_Sub(DEC_MID32(pDecRight), DEC_MID32(pDecLeft), &overflow);
4626  DEC_HI32(pDecOut) = VARIANT_Sub(DEC_HI32(pDecRight), DEC_HI32(pDecLeft), &overflow);
4627  }
4628  }
4629  else if (!DEC_SIGN(pDecLeft) && DEC_SIGN(pDecRight))
4630  {
4631  cmp = VARIANT_DecCmp(pDecLeft, pDecRight);
4632 
4633  /* x + -y : Negative if x <= y */
4634  if (cmp <= 0)
4635  {
4636  sign = DECIMAL_NEG;
4637  goto VarDecAdd_AsInvertedNegative;
4638  }
4639  goto VarDecAdd_AsNegative;
4640  }
4641  else
4642  {
4643  /* x + y : Positive */
4644 VarDecAdd_AsPositive:
4645  DEC_LO32(pDecOut) = VARIANT_Add(DEC_LO32(pDecLeft), DEC_LO32(pDecRight), &overflow);
4646  DEC_MID32(pDecOut) = VARIANT_Add(DEC_MID32(pDecLeft), DEC_MID32(pDecRight), &overflow);
4647  DEC_HI32(pDecOut) = VARIANT_Add(DEC_HI32(pDecLeft), DEC_HI32(pDecRight), &overflow);
4648  }
4649 
4650  if (overflow)
4651  return DISP_E_OVERFLOW; /* overflowed */
4652 
4653  DEC_SCALE(pDecOut) = DEC_SCALE(pDecLeft);
4654  DEC_SIGN(pDecOut) = sign;
4655  }
4656  return hRet;
4657 }
static size_t double int int int * sign
Definition: printf.c:69
static ULONG VARIANT_Add(ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
Definition: vartype.c:4519
#define DEC_LO32(d)
Definition: variant.h:96
#define cmp(status, error)
Definition: error.c:114
static int VARIANT_DecCmp(const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
Definition: vartype.c:4563
#define DEC_SIGN(d)
Definition: variant.h:91
LONG HRESULT
Definition: typedefs.h:77
#define DEC_HI32(d)
Definition: variant.h:94
unsigned char BYTE
Definition: mem.h:68
#define DECIMAL_POS
Definition: variant.h:77
static ULONG VARIANT_Sub(ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
Definition: vartype.c:4529
unsigned int ULONG
Definition: retypes.h:1
#define DEC_SCALE(d)
Definition: variant.h:92
#define DEC_MID32(d)
Definition: variant.h:95
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
static HRESULT VARIANT_DecScale(const DECIMAL **ppDecLeft, const DECIMAL **ppDecRight, DECIMAL pDecOut[2])
Definition: vartype.c:4437
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_VarDecAdd(), VarAdd(), and VarDecSub().

◆ VarDecCmp()

HRESULT WINAPI VarDecCmp ( const DECIMAL pDecLeft,
const DECIMAL pDecRight 
)

Definition at line 5865 of file vartype.c.

5866 {
5867  HRESULT hRet;
5868  DECIMAL result;
5869 
5870  if (!pDecLeft || !pDecRight)
5871  return VARCMP_NULL;
5872 
5873  if ((!(DEC_SIGN(pDecLeft) & DECIMAL_NEG)) && (DEC_SIGN(pDecRight) & DECIMAL_NEG) &&
5874  (DEC_HI32(pDecLeft) | DEC_MID32(pDecLeft) | DEC_LO32(pDecLeft)))
5875  return VARCMP_GT;
5876  else if ((DEC_SIGN(pDecLeft) & DECIMAL_NEG) && (!(DEC_SIGN(pDecRight) & DECIMAL_NEG)) &&
5877  (DEC_HI32(pDecLeft) | DEC_MID32(pDecLeft) | DEC_LO32(pDecLeft)))
5878  return VARCMP_LT;
5879 
5880  /* Subtract right from left, and compare the result to 0 */
5881  hRet = VarDecSub(pDecLeft, pDecRight, &result);
5882 
5883  if (SUCCEEDED(hRet))
5884  {
5885  int non_zero = DEC_HI32(&result) | DEC_MID32(&result) | DEC_LO32(&result);
5886 
5887  if ((DEC_SIGN(&result) & DECIMAL_NEG) && non_zero)
5888  hRet = (HRESULT)VARCMP_LT;
5889  else if (non_zero)
5890  hRet = (HRESULT)VARCMP_GT;
5891  else
5892  hRet = (HRESULT)VARCMP_EQ;
5893  }
5894  return hRet;
5895 }
#define HRESULT
Definition: msvc.h:9
#define DEC_LO32(d)
Definition: variant.h:96
#define VARCMP_LT
Definition: oleauto.h:657
#define VARCMP_EQ
Definition: oleauto.h:658
#define VARCMP_NULL
Definition: oleauto.h:660
#define DEC_SIGN(d)
Definition: variant.h:91
LONG HRESULT
Definition: typedefs.h:77
#define DEC_HI32(d)
Definition: variant.h:94
HRESULT WINAPI VarDecSub(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:5676
#define VARCMP_GT
Definition: oleauto.h:659
#define DEC_MID32(d)
Definition: variant.h:95
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_VarDecCmp(), VarCmp(), and VarDecCmpR8().

◆ VarDecCmpR8()

HRESULT WINAPI VarDecCmpR8 ( const DECIMAL pDecLeft,
double  dblRight 
)

Definition at line 5911 of file vartype.c.

5912 {
5913  HRESULT hRet;
5914  DECIMAL decRight;
5915 
5916  hRet = VarDecFromR8(dblRight, &decRight);
5917 
5918  if (SUCCEEDED(hRet))
5919  hRet = VarDecCmp(pDecLeft, &decRight);
5920 
5921  return hRet;
5922 }
HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL *pDecOut)
Definition: vartype.c:4199
HRESULT WINAPI VarDecCmp(const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
Definition: vartype.c:5865
LONG HRESULT
Definition: typedefs.h:77
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_VarDecCmpR8().

◆ VarDecDiv()

HRESULT WINAPI VarDecDiv ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 5600 of file vartype.c.

5601 {
5602  if (!pDecLeft || !pDecRight || !pDecOut) return E_INVALIDARG;
5603 
5604  return VARIANT_do_division(pDecLeft, pDecRight, pDecOut, FALSE);
5605 }
static HRESULT VARIANT_do_division(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut, BOOL round)
Definition: vartype.c:5530
#define E_INVALIDARG
Definition: ddrawi.h:101

Referenced by test_VarDecDiv(), and VarDiv().

◆ VarDecFix()

HRESULT WINAPI VarDecFix ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5721 of file vartype.c.

5722 {
5723  double dbl;
5724  HRESULT hr;
5725 
5726  if (DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
5727  return E_INVALIDARG;
5728 
5729  if (!DEC_SCALE(pDecIn))
5730  {
5731  *pDecOut = *pDecIn; /* Already an integer */
5732  return S_OK;
5733  }
5734 
5735  hr = VarR8FromDec(pDecIn, &dbl);
5736  if (SUCCEEDED(hr)) {
5737  LONGLONG rounded = dbl;
5738 
5739  hr = VarDecFromI8(rounded, pDecOut);
5740  }
5741  return hr;
5742 }
HRESULT hr
Definition: shlfolder.c:183
#define E_INVALIDARG
Definition: ddrawi.h:101
int64_t LONGLONG
Definition: typedefs.h:66
#define DEC_SIGN(d)
Definition: variant.h:91
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI VarDecFromI8(LONG64 llIn, DECIMAL *pDecOut)
Definition: vartype.c:4395
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI VarR8FromDec(const DECIMAL *pDecIn, double *pDblOut)
Definition: vartype.c:3266
#define DEC_SCALE(d)
Definition: variant.h:92
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by VarDecInt(), and VarFix().

◆ VarDecFromBool()

HRESULT WINAPI VarDecFromBool ( VARIANT_BOOL  bIn,
DECIMAL pDecOut 
)

Definition at line 4311 of file vartype.c.

4312 {
4313  DEC_HI32(pDecOut) = 0;
4314  DEC_MID32(pDecOut) = 0;
4315  if (bIn)
4316  {
4317  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4318  DEC_LO32(pDecOut) = 1;
4319  }
4320  else
4321  {
4322  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4323  DEC_LO32(pDecOut) = 0;
4324  }
4325  return S_OK;
4326 }
#define DEC_LO32(d)
Definition: variant.h:96
#define DEC_HI32(d)
Definition: variant.h:94
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
#define S_OK
Definition: intsafe.h:59
#define DECIMAL_POS
Definition: variant.h:77
#define DEC_SIGNSCALE(d)
Definition: variant.h:93
#define DEC_MID32(d)
Definition: variant.h:95

Referenced by test_VarDecFromBool().

◆ VarDecFromCy()

HRESULT WINAPI VarDecFromCy ( CY  cyIn,
DECIMAL pDecOut 
)

Definition at line 4238 of file vartype.c.

4239 {
4240  DEC_HI32(pDecOut) = 0;
4241 
4242  /* Note: This assumes 2s complement integer representation */
4243  if (cyIn.s.Hi & 0x80000000)
4244  {
4245  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,4);
4246  DEC_LO64(pDecOut) = -cyIn.int64;
4247  }
4248  else
4249  {
4250  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,4);
4251  DEC_MID32(pDecOut) = cyIn.s.Hi;
4252  DEC_LO32(pDecOut) = cyIn.s.Lo;
4253  }
4254  return S_OK;
4255 }
#define DEC_LO32(d)
Definition: variant.h:96
LONGLONG int64
Definition: compat.h:1914
#define DEC_HI32(d)
Definition: variant.h:94
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
#define S_OK
Definition: intsafe.h:59
#define DECIMAL_POS
Definition: variant.h:77
#define DEC_SIGNSCALE(d)
Definition: variant.h:93
#define DEC_LO64(d)
Definition: variant.h:97
ULONG Lo
Definition: compat.h:1910
#define DEC_MID32(d)
Definition: variant.h:95
LONG Hi
Definition: compat.h:1911

Referenced by test_VarDecFromCy(), and VARIANT_Coerce().

◆ VarDecFromDate()

HRESULT WINAPI VarDecFromDate ( DATE  dateIn,
DECIMAL pDecOut 
)

Definition at line 4221 of file vartype.c.

4222 {
4223  return VarDecFromR8(dateIn, pDecOut);
4224 }
HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL *pDecOut)
Definition: vartype.c:4199

Referenced by test_VarDecFromDate(), and VARIANT_Coerce().

◆ VarDecFromDisp()

HRESULT WINAPI VarDecFromDisp ( IDispatch pdispIn,
LCID  lcid,
DECIMAL pDecOut 
)

Definition at line 4291 of file vartype.c.

4292 {
4293  return VARIANT_FromDisp(pdispIn, lcid, pDecOut, VT_DECIMAL, 0);
4294 }
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:114

Referenced by VARIANT_Coerce().

◆ VarDecFromI1()

HRESULT WINAPI VarDecFromI1 ( signed char  cIn,
DECIMAL pDecOut 
)

Definition at line 4340 of file vartype.c.

4341 {
4342  return VarDecFromI4(cIn, pDecOut);
4343 }
HRESULT WINAPI VarDecFromI4(LONG lIn, DECIMAL *pDecOut)
Definition: vartype.c:4130

Referenced by test_VarDecFromI1(), and VARIANT_Coerce().

◆ VarDecFromI2()

HRESULT WINAPI VarDecFromI2 ( SHORT  sIn,
DECIMAL pDecOut 
)

Definition at line 4113 of file vartype.c.

4114 {
4115  return VarDecFromI4(sIn, pDecOut);
4116 }
HRESULT WINAPI VarDecFromI4(LONG lIn, DECIMAL *pDecOut)
Definition: vartype.c:4130

Referenced by test_VarDecFromI2(), and VARIANT_Coerce().

◆ VarDecFromI4()

HRESULT WINAPI VarDecFromI4 ( LONG  lIn,
DECIMAL pDecOut 
)

Definition at line 4130 of file vartype.c.

4131 {
4132  DEC_HI32(pDecOut) = 0;
4133  DEC_MID32(pDecOut) = 0;
4134 
4135  if (lIn < 0)
4136  {
4137  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4138  DEC_LO32(pDecOut) = -lIn;
4139  }
4140  else
4141  {
4142  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4143  DEC_LO32(pDecOut) = lIn;
4144  }
4145  return S_OK;
4146 }
#define DEC_LO32(d)
Definition: variant.h:96
#define DEC_HI32(d)
Definition: variant.h:94
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
#define S_OK
Definition: intsafe.h:59
#define DECIMAL_POS
Definition: variant.h:77
#define DEC_SIGNSCALE(d)
Definition: variant.h:93
#define DEC_MID32(d)
Definition: variant.h:95

Referenced by test_marshal_VARIANT(), test_VarDecFromI4(), test_VarMod(), VarDecFromI1(), VarDecFromI2(), and VARIANT_Coerce().

◆ VarDecFromI8()

HRESULT WINAPI VarDecFromI8 ( LONG64  llIn,
DECIMAL pDecOut 
)

Definition at line 4395 of file vartype.c.

4396 {
4397  PULARGE_INTEGER pLi = (PULARGE_INTEGER)&llIn;
4398 
4399  DEC_HI32(pDecOut) = 0;
4400 
4401  /* Note: This assumes 2s complement integer representation */
4402  if (pLi->u.HighPart & 0x80000000)
4403  {
4404  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4405  DEC_LO64(pDecOut) = -pLi->QuadPart;
4406  }
4407  else
4408  {
4409  DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMA