msi: Handle carriage returns in MsiDatabaseImport.
This commit is contained in:
parent
00cfd2899b
commit
ec086f77e3
@ -317,12 +317,18 @@ static void msi_parse_line(LPWSTR *line, LPWSTR **entries, DWORD *num_entries)
|
|||||||
/* store pointers into the data */
|
/* store pointers into the data */
|
||||||
for (i = 0, ptr = *line; i < count; i++)
|
for (i = 0, ptr = *line; i < count; i++)
|
||||||
{
|
{
|
||||||
|
while (*ptr && *ptr == '\r') ptr++;
|
||||||
save = ptr;
|
save = ptr;
|
||||||
|
|
||||||
while (*ptr && *ptr != '\t' && *ptr != '\n') ptr++;
|
while (*ptr && *ptr != '\t' && *ptr != '\n' && *ptr != '\r') ptr++;
|
||||||
|
|
||||||
/* NULL-separate the data */
|
/* NULL-separate the data */
|
||||||
if (*ptr)
|
if (*ptr == '\n' || *ptr == '\r')
|
||||||
|
{
|
||||||
|
while (*ptr == '\n' || *ptr == '\r')
|
||||||
|
*(ptr++) = '\0';
|
||||||
|
}
|
||||||
|
else if (*ptr)
|
||||||
*ptr++ = '\0';
|
*ptr++ = '\0';
|
||||||
|
|
||||||
(*entries)[i] = save;
|
(*entries)[i] = save;
|
||||||
@ -598,11 +604,11 @@ UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file)
|
|||||||
{
|
{
|
||||||
UINT r;
|
UINT r;
|
||||||
DWORD len, i;
|
DWORD len, i;
|
||||||
DWORD num_labels;
|
DWORD num_labels, num_types;
|
||||||
DWORD num_columns, num_records = 0;
|
DWORD num_columns, num_records = 0;
|
||||||
LPWSTR *columns, *types, *labels;
|
LPWSTR *columns, *types, *labels;
|
||||||
LPWSTR path, ptr, data;
|
LPWSTR path, ptr, data;
|
||||||
LPWSTR **records;
|
LPWSTR **records = NULL;
|
||||||
LPWSTR **temp_records;
|
LPWSTR **temp_records;
|
||||||
|
|
||||||
static const WCHAR backslash[] = {'\\',0};
|
static const WCHAR backslash[] = {'\\',0};
|
||||||
@ -625,9 +631,15 @@ UINT MSI_DatabaseImport(MSIDATABASE *db, LPCWSTR folder, LPCWSTR file)
|
|||||||
|
|
||||||
ptr = data;
|
ptr = data;
|
||||||
msi_parse_line( &ptr, &columns, &num_columns );
|
msi_parse_line( &ptr, &columns, &num_columns );
|
||||||
msi_parse_line( &ptr, &types, NULL );
|
msi_parse_line( &ptr, &types, &num_types );
|
||||||
msi_parse_line( &ptr, &labels, &num_labels );
|
msi_parse_line( &ptr, &labels, &num_labels );
|
||||||
|
|
||||||
|
if (num_columns != num_types)
|
||||||
|
{
|
||||||
|
r = ERROR_FUNCTION_FAILED;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
records = msi_alloc(sizeof(LPWSTR *));
|
records = msi_alloc(sizeof(LPWSTR *));
|
||||||
if (!records)
|
if (!records)
|
||||||
{
|
{
|
||||||
|
@ -272,6 +272,7 @@ static void create_database(const CHAR *name, const msi_table *tables, int num_t
|
|||||||
|
|
||||||
write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
|
write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
|
||||||
|
|
||||||
|
printf("table->filename: %s\n", table->filename);
|
||||||
r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
|
r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
|
||||||
|
|
||||||
|
@ -1643,10 +1643,7 @@ static void test_msiimport(void)
|
|||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
|
|
||||||
r = add_table_to_db(hdb, endlines1);
|
r = add_table_to_db(hdb, endlines1);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = add_table_to_db(hdb, endlines2);
|
r = add_table_to_db(hdb, endlines2);
|
||||||
ok(r == ERROR_FUNCTION_FAILED,
|
ok(r == ERROR_FUNCTION_FAILED,
|
||||||
@ -1749,7 +1746,8 @@ static void test_msiimport(void)
|
|||||||
MsiCloseHandle(rec);
|
MsiCloseHandle(rec);
|
||||||
|
|
||||||
r = MsiViewFetch(view, &rec);
|
r = MsiViewFetch(view, &rec);
|
||||||
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
|
ok(r == ERROR_NO_MORE_ITEMS,
|
||||||
|
"Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
|
||||||
|
|
||||||
r = MsiViewClose(view);
|
r = MsiViewClose(view);
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
@ -1758,37 +1756,28 @@ static void test_msiimport(void)
|
|||||||
|
|
||||||
query = "SELECT * FROM `Table`";
|
query = "SELECT * FROM `Table`";
|
||||||
r = MsiDatabaseOpenView(hdb, query, &view);
|
r = MsiDatabaseOpenView(hdb, query, &view);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = MsiViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
|
r = MsiViewGetColumnInfo(view, MSICOLINFO_NAMES, &rec);
|
||||||
count = MsiRecordGetFieldCount(rec);
|
count = MsiRecordGetFieldCount(rec);
|
||||||
todo_wine
|
ok(count == 6, "Expected 6, got %d\n", count);
|
||||||
{
|
ok(check_record(rec, 1, "A"), "Expected A\n");
|
||||||
ok(count == 6, "Expected 6, got %d\n", count);
|
ok(check_record(rec, 2, "B"), "Expected B\n");
|
||||||
ok(check_record(rec, 1, "A"), "Expected A\n");
|
ok(check_record(rec, 3, "C"), "Expected C\n");
|
||||||
ok(check_record(rec, 2, "B"), "Expected B\n");
|
ok(check_record(rec, 4, "D"), "Expected D\n");
|
||||||
ok(check_record(rec, 3, "C"), "Expected C\n");
|
ok(check_record(rec, 5, "E"), "Expected E\n");
|
||||||
ok(check_record(rec, 4, "D"), "Expected D\n");
|
ok(check_record(rec, 6, "F"), "Expected F\n");
|
||||||
ok(check_record(rec, 5, "E"), "Expected E\n");
|
|
||||||
ok(check_record(rec, 6, "F"), "Expected F\n");
|
|
||||||
}
|
|
||||||
MsiCloseHandle(rec);
|
MsiCloseHandle(rec);
|
||||||
|
|
||||||
r = MsiViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
|
r = MsiViewGetColumnInfo(view, MSICOLINFO_TYPES, &rec);
|
||||||
count = MsiRecordGetFieldCount(rec);
|
count = MsiRecordGetFieldCount(rec);
|
||||||
todo_wine
|
ok(count == 6, "Expected 6, got %d\n", count);
|
||||||
{
|
ok(check_record(rec, 1, "s72"), "Expected s72\n");
|
||||||
ok(count == 6, "Expected 6, got %d\n", count);
|
ok(check_record(rec, 2, "s72"), "Expected s72\n");
|
||||||
ok(check_record(rec, 1, "s72"), "Expected s72\n");
|
ok(check_record(rec, 3, "s72"), "Expected s72\n");
|
||||||
ok(check_record(rec, 2, "s72"), "Expected s72\n");
|
ok(check_record(rec, 4, "s72"), "Expected s72\n");
|
||||||
ok(check_record(rec, 3, "s72"), "Expected s72\n");
|
ok(check_record(rec, 5, "s72"), "Expected s72\n");
|
||||||
ok(check_record(rec, 4, "s72"), "Expected s72\n");
|
ok(check_record(rec, 6, "s72"), "Expected s72\n");
|
||||||
ok(check_record(rec, 5, "s72"), "Expected s72\n");
|
|
||||||
ok(check_record(rec, 6, "s72"), "Expected s72\n");
|
|
||||||
}
|
|
||||||
MsiCloseHandle(rec);
|
MsiCloseHandle(rec);
|
||||||
|
|
||||||
MsiViewClose(view);
|
MsiViewClose(view);
|
||||||
@ -1796,51 +1785,36 @@ static void test_msiimport(void)
|
|||||||
|
|
||||||
query = "SELECT * FROM `Table`";
|
query = "SELECT * FROM `Table`";
|
||||||
r = MsiDatabaseOpenView(hdb, query, &view);
|
r = MsiDatabaseOpenView(hdb, query, &view);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = MsiViewExecute(view, 0);
|
r = MsiViewExecute(view, 0);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = MsiViewFetch(view, &rec);
|
r = MsiViewFetch(view, &rec);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
ok(check_record(rec, 1, "a"), "Expected 'a'\n");
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
ok(check_record(rec, 2, "b"), "Expected 'b'\n");
|
||||||
ok(check_record(rec, 1, "a"), "Expected 'a'\n");
|
ok(check_record(rec, 3, "c"), "Expected 'c'\n");
|
||||||
ok(check_record(rec, 2, "b"), "Expected 'b'\n");
|
ok(check_record(rec, 4, "d"), "Expected 'd'\n");
|
||||||
ok(check_record(rec, 3, "c"), "Expected 'c'\n");
|
ok(check_record(rec, 5, "e"), "Expected 'e'\n");
|
||||||
ok(check_record(rec, 4, "d"), "Expected 'd'\n");
|
ok(check_record(rec, 6, "f"), "Expected 'f'\n");
|
||||||
ok(check_record(rec, 5, "e"), "Expected 'e'\n");
|
|
||||||
ok(check_record(rec, 6, "f"), "Expected 'f'\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
MsiCloseHandle(rec);
|
MsiCloseHandle(rec);
|
||||||
|
|
||||||
r = MsiViewFetch(view, &rec);
|
r = MsiViewFetch(view, &rec);
|
||||||
todo_wine
|
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||||
{
|
ok(check_record(rec, 1, "g"), "Expected 'g'\n");
|
||||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
ok(check_record(rec, 2, "h"), "Expected 'h'\n");
|
||||||
ok(check_record(rec, 1, "g"), "Expected 'g'\n");
|
ok(check_record(rec, 3, "i"), "Expected 'i'\n");
|
||||||
ok(check_record(rec, 2, "h"), "Expected 'h'\n");
|
ok(check_record(rec, 4, "j"), "Expected 'j'\n");
|
||||||
ok(check_record(rec, 3, "i"), "Expected 'i'\n");
|
ok(check_record(rec, 5, "k"), "Expected 'k'\n");
|
||||||
ok(check_record(rec, 4, "j"), "Expected 'j'\n");
|
ok(check_record(rec, 6, "l"), "Expected 'l'\n");
|
||||||
ok(check_record(rec, 5, "k"), "Expected 'k'\n");
|
|
||||||
ok(check_record(rec, 6, "l"), "Expected 'l'\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
MsiCloseHandle(rec);
|
MsiCloseHandle(rec);
|
||||||
|
|
||||||
r = MsiViewFetch(view, &rec);
|
r = MsiViewFetch(view, &rec);
|
||||||
todo_wine
|
ok(r == ERROR_NO_MORE_ITEMS,
|
||||||
{
|
"Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
|
||||||
ok(r == ERROR_NO_MORE_ITEMS,
|
|
||||||
"Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
MsiViewClose(view);
|
MsiViewClose(view);
|
||||||
MsiCloseHandle(view);
|
MsiCloseHandle(view);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user