[PATCH 4/4] regedit: Re-implement processSetValue()
Hugh McMaster
hugh.mcmaster at outlook.com
Mon Apr 24 08:49:12 CDT 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/regedit.rc | 1 +
programs/regedit/regproc.c | 74 ++++++++++++++++------------------------
programs/regedit/resource.h | 1 +
programs/regedit/tests/regedit.c | 4 +--
4 files changed, 34 insertions(+), 46 deletions(-)
diff --git a/programs/regedit/regedit.rc b/programs/regedit/regedit.rc
index 1d9b6cb..28fa0f5 100644
--- a/programs/regedit/regedit.rc
+++ b/programs/regedit/regedit.rc
@@ -394,6 +394,7 @@ STRINGTABLE
STRING_REG_KEY_NOT_FOUND, "regedit: Unable to export '%1'. The specified registry key was not found.\n"
STRING_DELETE_REG_CLASS_FAILED, "regedit: Unable to delete the registry class '%1'.\n"
STRING_UNKNOWN_TYPE, "Unknown Type"
+ STRING_INVALID_LINE_SYNTAX, "regedit: The line contains invalid syntax.\n"
}
/* define language neutral resources */
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 60d911e..9b8f44f 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -532,61 +532,47 @@ static void closeKey(void)
*/
static void processSetValue(WCHAR* line, BOOL is_unicode)
{
- WCHAR* val_name; /* registry value name */
- WCHAR* val_data; /* registry value data */
- WCHAR* p;
- int line_idx = 0; /* current character under analysis */
+ WCHAR *val_name;
+ int len = 0;
LONG res;
/* get value name */
- while ( isspaceW(line[line_idx]) ) line_idx++;
- if (line[line_idx] == '@' && line[line_idx + 1] == '=') {
- line[line_idx] = '\0';
- val_name = line;
- line_idx++;
- } else if (line[line_idx] == '\"') {
- line_idx++;
- val_name = line + line_idx;
- while (line[line_idx]) {
- if (line[line_idx] == '\\') /* skip escaped character */
- {
- line_idx += 2;
- } else {
- if (line[line_idx] == '\"') {
- line[line_idx] = '\0';
- line_idx++;
- break;
- } else {
- line_idx++;
- }
- }
- }
- while ( isspaceW(line[line_idx]) ) line_idx++;
- if (!line[line_idx]) {
- output_message(STRING_UNEXPECTED_EOL, line);
- return;
- }
- if (line[line_idx] != '=') {
- line[line_idx] = '\"';
- output_message(STRING_UNRECOGNIZED_LINE, line);
+ while (*line == ' ' || *line == '\t') line++;
+ val_name = line;
+
+ if (*line == '@')
+ *line++ = 0;
+ else if (*line == '"')
+ {
+ if (!REGPROC_unescape_string(++val_name, &line))
+ {
+ output_message(STRING_SETVALUE_FAILED, val_name, currentKeyName);
+ output_message(STRING_INVALID_LINE_SYNTAX);
return;
}
-
- } else {
+ }
+ else
+ {
output_message(STRING_UNRECOGNIZED_LINE, line);
return;
}
- line_idx++; /* skip the '=' character */
- while ( isspaceW(line[line_idx]) ) line_idx++;
- val_data = line + line_idx;
+ while (*line == ' ' || *line == '\t') line++;
+ if (*line != '=')
+ {
+ output_message(STRING_SETVALUE_FAILED, val_name, currentKeyName);
+ output_message(STRING_INVALID_LINE_SYNTAX);
+ return;
+ }
+ line++; /* skip '=' character */
+ while (*line == ' ' || *line == '\t') line++;
+
/* trim trailing blanks */
- line_idx = strlenW(val_data);
- while (line_idx > 0 && isspaceW(val_data[line_idx-1])) line_idx--;
- val_data[line_idx] = '\0';
+ len = strlenW(line);
+ while (len > 0 && (line[len - 1] == ' ' || line[len - 1] == '\t')) len--;
+ line[len] = 0;
- REGPROC_unescape_string(val_name, &p);
- res = setValue(val_name, val_data, is_unicode);
+ res = setValue(val_name, line, is_unicode);
if ( res != ERROR_SUCCESS )
output_message(STRING_SETVALUE_FAILED, val_name, currentKeyName);
}
diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h
index 295d9b4..5076a7b 100644
--- a/programs/regedit/resource.h
+++ b/programs/regedit/resource.h
@@ -195,3 +195,4 @@
#define STRING_REG_KEY_NOT_FOUND 3021
#define STRING_DELETE_REG_CLASS_FAILED 3022
#define STRING_UNKNOWN_TYPE 3023
+#define STRING_INVALID_LINE_SYNTAX 3024
diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index 8010a47..b060e92 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -859,12 +859,12 @@ static void test_import_with_whitespace(void)
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
"@ = \"Test Value\"\n\n");
- todo_wine verify_reg(hkey, "", REG_SZ, "Test Value", 11, 0);
+ verify_reg(hkey, "", REG_SZ, "Test Value", 11, 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
"\t@\t=\tdword:\t00000008\t\n\n");
- todo_wine verify_reg(hkey, "", REG_DWORD, &dword, sizeof(DWORD), 0);
+ verify_reg(hkey, "", REG_DWORD, &dword, sizeof(DWORD), 0);
lr = RegCloseKey(hkey);
ok(lr == ERROR_SUCCESS, "RegCloseKey failed: got %d, expected 0\n", lr);
--
2.7.4
More information about the wine-patches
mailing list