reg: Delete registry values via the state machine.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-08-18 09:31:08 +00:00 committed by Alexandre Julliard
parent db98cc4ced
commit d90f2a55bf
2 changed files with 27 additions and 12 deletions

View File

@ -69,6 +69,7 @@ enum parser_state
DEFAULT_VALUE_NAME, /* parsing a default value name */
QUOTED_VALUE_NAME, /* parsing a double-quoted value name */
DATA_START, /* preparing for data parsing operations */
DELETE_VALUE, /* deleting a registry value */
DATA_TYPE, /* parsing the registry data type */
STRING_DATA, /* parsing REG_SZ data */
DWORD_DATA, /* parsing DWORD data */
@ -107,6 +108,7 @@ static WCHAR *key_name_state(struct parser *parser, WCHAR *pos);
static WCHAR *default_value_name_state(struct parser *parser, WCHAR *pos);
static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos);
static WCHAR *data_start_state(struct parser *parser, WCHAR *pos);
static WCHAR *delete_value_state(struct parser *parser, WCHAR *pos);
static WCHAR *data_type_state(struct parser *parser, WCHAR *pos);
static WCHAR *string_data_state(struct parser *parser, WCHAR *pos);
static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos);
@ -125,6 +127,7 @@ static const parser_state_func parser_funcs[NB_PARSER_STATES] =
default_value_name_state, /* DEFAULT_VALUE_NAME */
quoted_value_name_state, /* QUOTED_VALUE_NAME */
data_start_state, /* DATA_START */
delete_value_state, /* DELETE_VALUE */
data_type_state, /* DATA_TYPE */
string_data_state, /* STRING_DATA */
dword_data_state, /* DWORD_DATA */
@ -642,10 +645,7 @@ static WCHAR *data_start_state(struct parser *parser, WCHAR *pos)
p[len] = 0;
if (*p == '-')
{
FIXME("value deletion not yet implemented\n");
goto invalid;
}
set_state(parser, DELETE_VALUE);
else
set_state(parser, DATA_TYPE);
return p;
@ -655,6 +655,21 @@ invalid:
return p;
}
/* handler for parser DELETE_VALUE state */
static WCHAR *delete_value_state(struct parser *parser, WCHAR *pos)
{
WCHAR *p = pos + 1;
while (*p == ' ' || *p == '\t') p++;
if (*p && *p != ';') goto done;
RegDeleteValueW(parser->hkey, parser->value_name);
done:
set_state(parser, LINE_START);
return p;
}
/* handler for parser DATA_TYPE state */
static WCHAR *data_type_state(struct parser *parser, WCHAR *pos)
{

View File

@ -1758,11 +1758,11 @@ static void test_import(void)
"\"Wine46e\"=- ;comment\n"
"\"Wine46f\"=- #comment\n\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg_nonexist(hkey, "Wine46a");
todo_wine verify_reg_nonexist(hkey, "Wine46b");
todo_wine verify_reg_nonexist(hkey, "Wine46c");
verify_reg_nonexist(hkey, "Wine46a");
verify_reg_nonexist(hkey, "Wine46b");
verify_reg_nonexist(hkey, "Wine46c");
verify_reg(hkey, "Wine46d", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
todo_wine verify_reg_nonexist(hkey, "Wine46e");
verify_reg_nonexist(hkey, "Wine46e");
verify_reg(hkey, "Wine46f", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
/* Test the accepted range of the hex-based data types */
@ -3215,11 +3215,11 @@ static void test_unicode_import(void)
"\"Wine46e\"=- ;comment\n"
"\"Wine46f\"=- #comment\n\n", &r);
todo_wine ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
todo_wine verify_reg_nonexist(hkey, "Wine46a");
todo_wine verify_reg_nonexist(hkey, "Wine46b");
todo_wine verify_reg_nonexist(hkey, "Wine46c");
verify_reg_nonexist(hkey, "Wine46a");
verify_reg_nonexist(hkey, "Wine46b");
verify_reg_nonexist(hkey, "Wine46c");
verify_reg(hkey, "Wine46d", REG_MULTI_SZ, "Line concatenation\0", 20, 0);
todo_wine verify_reg_nonexist(hkey, "Wine46e");
verify_reg_nonexist(hkey, "Wine46e");
verify_reg(hkey, "Wine46f", REG_NONE, "V\0a\0l\0u\0e\0\0", 12, 0);
/* Test the accepted range of the hex-based data types */