[WINESYNC] msi: Use nameless unions.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id cc2cc1463a493651f765fe18852a16c01184ad92 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
winesync 2022-03-13 21:43:46 +01:00 committed by Mark Jansen
parent a3e22d8922
commit 4bf22783a8
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 26 additions and 27 deletions

View file

@ -42,7 +42,6 @@ list(APPEND SOURCE
storages.c storages.c
streams.c streams.c
string.c string.c
suminfo.c
table.c table.c
tokenize.c tokenize.c
update.c update.c
@ -59,6 +58,7 @@ add_rpc_files(server winemsi.idl)
set(IDL_FLAGS ${OLD_IDL_FLAGS}) set(IDL_FLAGS ${OLD_IDL_FLAGS})
list(APPEND PCH_SKIP_SOURCE list(APPEND PCH_SKIP_SOURCE
suminfo.c # The only file without NONAMELESSUNION
${BISON_cond_OUTPUTS} ${BISON_cond_OUTPUTS}
${BISON_sql_OUTPUTS} ${BISON_sql_OUTPUTS}
${CMAKE_CURRENT_BINARY_DIR}/msiserver_i.c ${CMAKE_CURRENT_BINARY_DIR}/msiserver_i.c

View file

@ -21,7 +21,6 @@
#include <stdarg.h> #include <stdarg.h>
#define COBJMACROS #define COBJMACROS
#define NONAMELESSUNION
#include "stdio.h" #include "stdio.h"
#include "windef.h" #include "windef.h"
@ -91,7 +90,7 @@ static HRESULT (WINAPI *pPropVariantChangeType)
static void free_prop( PROPVARIANT *prop ) static void free_prop( PROPVARIANT *prop )
{ {
if (prop->vt == VT_LPSTR ) if (prop->vt == VT_LPSTR )
msi_free( prop->u.pszVal ); msi_free( prop->pszVal );
prop->vt = VT_EMPTY; prop->vt = VT_EMPTY;
} }
@ -227,14 +226,14 @@ static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz
LPSTR str = msi_alloc( propdata->u.str.len ); LPSTR str = msi_alloc( propdata->u.str.len );
memcpy( str, propdata->u.str.str, propdata->u.str.len ); memcpy( str, propdata->u.str.str, propdata->u.str.len );
str[ propdata->u.str.len - 1 ] = 0; str[ propdata->u.str.len - 1 ] = 0;
property.u.pszVal = str; property.pszVal = str;
} }
else if( propdata->type == VT_FILETIME ) else if( propdata->type == VT_FILETIME )
property.u.filetime = propdata->u.ft; property.filetime = propdata->u.ft;
else if( propdata->type == VT_I2 ) else if( propdata->type == VT_I2 )
property.u.iVal = propdata->u.i2; property.iVal = propdata->u.i2;
else if( propdata->type == VT_I4 ) else if( propdata->type == VT_I4 )
property.u.lVal = propdata->u.i4; property.lVal = propdata->u.i4;
/* check the type is the same as we expect */ /* check the type is the same as we expect */
if( type != propdata->type ) if( type != propdata->type )
@ -358,16 +357,16 @@ static UINT write_property_to_data( const PROPVARIANT *prop, LPBYTE data )
switch( prop->vt ) switch( prop->vt )
{ {
case VT_I2: case VT_I2:
sz += write_dword( data, sz, prop->u.iVal ); sz += write_dword( data, sz, prop->iVal );
break; break;
case VT_I4: case VT_I4:
sz += write_dword( data, sz, prop->u.lVal ); sz += write_dword( data, sz, prop->lVal );
break; break;
case VT_FILETIME: case VT_FILETIME:
sz += write_filetime( data, sz, &prop->u.filetime ); sz += write_filetime( data, sz, &prop->filetime );
break; break;
case VT_LPSTR: case VT_LPSTR:
sz += write_string( data, sz, prop->u.pszVal ); sz += write_string( data, sz, prop->pszVal );
break; break;
} }
return sz; return sz;
@ -656,11 +655,11 @@ static UINT get_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT *puiDataType, IN
{ {
case VT_I2: case VT_I2:
if( piValue ) if( piValue )
*piValue = prop->u.iVal; *piValue = prop->iVal;
break; break;
case VT_I4: case VT_I4:
if( piValue ) if( piValue )
*piValue = prop->u.lVal; *piValue = prop->lVal;
break; break;
case VT_LPSTR: case VT_LPSTR:
if( pcchValueBuf ) if( pcchValueBuf )
@ -669,14 +668,14 @@ static UINT get_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT *puiDataType, IN
if( str->unicode ) if( str->unicode )
{ {
len = MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1, NULL, 0 ) - 1; len = MultiByteToWideChar( CP_ACP, 0, prop->pszVal, -1, NULL, 0 ) - 1;
MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1, str->str.w, *pcchValueBuf ); MultiByteToWideChar( CP_ACP, 0, prop->pszVal, -1, str->str.w, *pcchValueBuf );
} }
else else
{ {
len = lstrlenA( prop->u.pszVal ); len = lstrlenA( prop->pszVal );
if( str->str.a ) if( str->str.a )
lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf ); lstrcpynA(str->str.a, prop->pszVal, *pcchValueBuf );
} }
if (len >= *pcchValueBuf) if (len >= *pcchValueBuf)
ret = ERROR_MORE_DATA; ret = ERROR_MORE_DATA;
@ -685,7 +684,7 @@ static UINT get_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT *puiDataType, IN
break; break;
case VT_FILETIME: case VT_FILETIME:
if( pftValue ) if( pftValue )
*pftValue = prop->u.filetime; *pftValue = prop->filetime;
break; break;
case VT_EMPTY: case VT_EMPTY:
break; break;
@ -705,7 +704,7 @@ LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty )
prop = &si->property[uiProperty]; prop = &si->property[uiProperty];
if( prop->vt != VT_LPSTR ) if( prop->vt != VT_LPSTR )
return NULL; return NULL;
return strdupAtoW( prop->u.pszVal ); return strdupAtoW( prop->pszVal );
} }
INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty ) INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty )
@ -717,7 +716,7 @@ INT msi_suminfo_get_int32( MSISUMMARYINFO *si, UINT uiProperty )
prop = &si->property[uiProperty]; prop = &si->property[uiProperty];
if( prop->vt != VT_I4 ) if( prop->vt != VT_I4 )
return -1; return -1;
return prop->u.lVal; return prop->lVal;
} }
LPWSTR msi_get_suminfo_product( IStorage *stg ) LPWSTR msi_get_suminfo_product( IStorage *stg )
@ -864,28 +863,28 @@ static UINT set_prop( MSISUMMARYINFO *si, UINT uiProperty, UINT type,
switch( type ) switch( type )
{ {
case VT_I4: case VT_I4:
prop->u.lVal = iValue; prop->lVal = iValue;
break; break;
case VT_I2: case VT_I2:
prop->u.iVal = iValue; prop->iVal = iValue;
break; break;
case VT_FILETIME: case VT_FILETIME:
prop->u.filetime = *pftValue; prop->filetime = *pftValue;
break; break;
case VT_LPSTR: case VT_LPSTR:
if( str->unicode ) if( str->unicode )
{ {
len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1, len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
NULL, 0, NULL, NULL ); NULL, 0, NULL, NULL );
prop->u.pszVal = msi_alloc( len ); prop->pszVal = msi_alloc( len );
WideCharToMultiByte( CP_ACP, 0, str->str.w, -1, WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
prop->u.pszVal, len, NULL, NULL ); prop->pszVal, len, NULL, NULL );
} }
else else
{ {
len = lstrlenA( str->str.a ) + 1; len = lstrlenA( str->str.a ) + 1;
prop->u.pszVal = msi_alloc( len ); prop->pszVal = msi_alloc( len );
lstrcpyA( prop->u.pszVal, str->str.a ); lstrcpyA( prop->pszVal, str->str.a );
} }
break; break;
} }