mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-05 18:49:33 +00:00
msi: Fix creation of the default format in MsiFormatRecord.
This commit is contained in:
parent
ad2ec01739
commit
a248cc8f62
|
@ -50,19 +50,53 @@ static LPWSTR build_default_format(MSIRECORD* record)
|
|||
{
|
||||
int i;
|
||||
int count;
|
||||
LPWSTR rc;
|
||||
static const WCHAR fmt[] = {'%','i',':',' ','[','%','i',']',' ',0};
|
||||
WCHAR buf[11];
|
||||
LPWSTR rc, buf;
|
||||
static const WCHAR fmt[] = {'%','i',':',' ','%','s',' ',0};
|
||||
static const WCHAR fmt_null[] = {'%','i',':',' ',' ',0};
|
||||
static const WCHAR fmt_index[] = {'%','i',0};
|
||||
LPCWSTR str;
|
||||
WCHAR index[10];
|
||||
DWORD size, max_len, len;
|
||||
|
||||
count = MSI_RecordGetFieldCount(record);
|
||||
|
||||
rc = msi_alloc((11*count)*sizeof(WCHAR));
|
||||
rc[0] = 0;
|
||||
max_len = MAX_PATH;
|
||||
buf = msi_alloc((max_len + 1) * sizeof(WCHAR));
|
||||
|
||||
rc = NULL;
|
||||
size = 1;
|
||||
for (i = 1; i <= count; i++)
|
||||
{
|
||||
sprintfW(buf,fmt,i,i);
|
||||
strcatW(rc,buf);
|
||||
sprintfW(index,fmt_index,i);
|
||||
str = MSI_RecordGetString(record, i);
|
||||
len = (str) ? lstrlenW(str) : 0;
|
||||
len += (sizeof(fmt_null) - 3) + lstrlenW(index);
|
||||
size += len;
|
||||
|
||||
if (len > max_len)
|
||||
{
|
||||
max_len = len;
|
||||
buf = msi_realloc(buf, (max_len + 1) * sizeof(WCHAR));
|
||||
if (!buf) return NULL;
|
||||
}
|
||||
|
||||
if (str)
|
||||
sprintfW(buf,fmt,i,str);
|
||||
else
|
||||
sprintfW(buf,fmt_null,i);
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
rc = msi_alloc(size * sizeof(WCHAR));
|
||||
lstrcpyW(rc, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = msi_realloc(rc, size * sizeof(WCHAR));
|
||||
lstrcatW(rc, buf);
|
||||
}
|
||||
}
|
||||
msi_free(buf);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1501,6 +1501,24 @@ static void test_formatrecord_package(void)
|
|||
ok( sz == 51, "size wrong (%li)\n",sz);
|
||||
ok( 0 == strcmp(buffer,"1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer);
|
||||
|
||||
r = MsiSetProperty(package, "prop", "val");
|
||||
ok( r == ERROR_SUCCESS, "failed to set propertY: %d\n", r);
|
||||
|
||||
r = MsiRecordSetString(hrec, 0, NULL);
|
||||
r = MsiRecordSetString(hrec, 1, "[2]");
|
||||
r = MsiRecordSetString(hrec, 2, "stuff");
|
||||
r = MsiRecordSetString(hrec, 3, "prop");
|
||||
r = MsiRecordSetString(hrec, 4, "[prop]");
|
||||
r = MsiRecordSetString(hrec, 5, "[noprop]");
|
||||
sz = sizeof buffer;
|
||||
r = MsiFormatRecord(package, hrec, buffer, &sz);
|
||||
ok( r == ERROR_SUCCESS, "format failed with empty buffer (%i)\n",r);
|
||||
todo_wine
|
||||
{
|
||||
ok( sz == 66, "size wrong (%li)\n",sz);
|
||||
ok( 0 == strcmp(buffer,"1: [2] 2: stuff 3: prop 4: val 5: 6: 7: 8: 9: 10: 11: 12: "), "wrong output(%s)\n",buffer);
|
||||
}
|
||||
|
||||
/* now put play games with escaping */
|
||||
r = MsiRecordSetString(hrec, 0, "[1] [2] [\\3asdf]");
|
||||
r = MsiRecordSetString(hrec, 1, "boo");
|
||||
|
@ -1715,33 +1733,25 @@ static void test_formatrecord_tables(void)
|
|||
|
||||
/* property doesn't exist */
|
||||
size = MAX_PATH;
|
||||
/*MsiRecordSetString( hrec, 0, "[1]" ); */
|
||||
MsiRecordSetString( hrec, 1, "[idontexist]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
|
||||
/* property exists */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[imaprop]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf );
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: ringer " ), "Expected '1: ringer ', got %s\n", buf );
|
||||
|
||||
/* environment variable doesn't exist */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[%idontexist]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
|
||||
/* environment variable exists */
|
||||
size = MAX_PATH;
|
||||
|
@ -1749,20 +1759,14 @@ static void test_formatrecord_tables(void)
|
|||
MsiRecordSetString( hrec, 1, "[%crazyvar]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf );
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: crazyval " ), "Expected '1: crazyval ', got %s\n", buf );
|
||||
|
||||
/* file key before CostInitialize */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[#frontal_file]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: " ), "Expected '1: ', got %s\n", buf );
|
||||
|
||||
r = MsiDoAction(hpkg, "CostInitialize");
|
||||
ok( r == ERROR_SUCCESS, "CostInitialize failed: %d\n", r);
|
||||
|
@ -1778,31 +1782,22 @@ static void test_formatrecord_tables(void)
|
|||
MsiRecordSetString( hrec, 1, "[#frontal_file]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: C:\\frontal.txt " ), "Expected '1: C:\\frontal.txt ', got %s\n", buf);
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: C:\\frontal.txt " ), "Expected '1: C:\\frontal.txt ', got %s\n", buf);
|
||||
|
||||
/* frontal short file key */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[!frontal_file]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: C:\\frontal.txt " ), "Expected '1: C:\\frontal.txt ', got %s\n", buf);
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: C:\\frontal.txt " ), "Expected '1: C:\\frontal.txt ', got %s\n", buf);
|
||||
|
||||
/* temporal full file key */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[#temporal_file]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
{
|
||||
ok( !lstrcmp( buf, "1: C:\\I am a really long directory\\temporal.txt " ),
|
||||
"Expected '1: C:\\I am a really long directory\\temporal.txt ', got %s\n", buf);
|
||||
}
|
||||
ok( !lstrcmp( buf, "1: C:\\I am a really long directory\\temporal.txt " ),
|
||||
"Expected '1: C:\\I am a really long directory\\temporal.txt ', got %s\n", buf);
|
||||
|
||||
/* temporal short file key */
|
||||
size = MAX_PATH;
|
||||
|
@ -1846,7 +1841,7 @@ static void test_formatrecord_tables(void)
|
|||
|
||||
/* component with INSTALLSTATE_LOCAL */
|
||||
size = MAX_PATH;
|
||||
MsiRecordSetString( hrec, 1, "[$temporal]" );
|
||||
MsiRecordSetString( hrec, 0, "[$temporal]" );
|
||||
r = MsiFormatRecord( hpkg, hrec, buf, &size );
|
||||
ok( r == ERROR_SUCCESS, "format record failed: %d\n", r);
|
||||
todo_wine
|
||||
|
|
Loading…
Reference in a new issue