[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master cbbea70 3/5: addpm.c: Replace existing entries, but
From: |
Juanma Barranquero |
Subject: |
[Emacs-diffs] master cbbea70 3/5: addpm.c: Replace existing entries, but do not create new ones |
Date: |
Sat, 24 Oct 2015 23:16:25 +0000 |
branch: master
commit cbbea701c6956961b55ed754fbfe2ae6329f940b
Author: Juanma Barranquero <address@hidden>
Commit: Juanma Barranquero <address@hidden>
addpm.c: Replace existing entries, but do not create new ones
* nt/addpm.c (add_registry): If the Emacs registry key exists, replace
existing values from previous versions, but do not add new ones; the
key could exist for other reasons unrelated to old Emacsen, like X-style
resources, or to set some environment variables like HOME or LANG, and
in that case we don't want to populate it with obsolete values.
---
nt/addpm.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/nt/addpm.c b/nt/addpm.c
index ba0eb36..caa3272 100644
--- a/nt/addpm.c
+++ b/nt/addpm.c
@@ -186,17 +186,20 @@ add_registry (const char *path)
have any resources. */
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0,
- KEY_WRITE, &hrootkey) != ERROR_SUCCESS
+ KEY_WRITE | KEY_QUERY_VALUE, &hrootkey) != ERROR_SUCCESS
&& RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0,
- KEY_WRITE, &hrootkey) != ERROR_SUCCESS)
+ KEY_WRITE | KEY_QUERY_VALUE, &hrootkey) != ERROR_SUCCESS)
return;
for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
{
const char * value = env_vars[i].value ? env_vars[i].value : path;
- RegSetValueEx (hrootkey, env_vars[i].name, 0, REG_EXPAND_SZ,
- value, lstrlen (value) + 1);
+ /* Replace only those settings that already exist. */
+ if (RegQueryValueEx (hrootkey, env_vars[i].name, NULL,
+ NULL, NULL, NULL) == ERROR_SUCCESS)
+ RegSetValueEx (hrootkey, env_vars[i].name, 0, REG_EXPAND_SZ,
+ value, lstrlen (value) + 1);
}
RegCloseKey (hrootkey);
- [Emacs-diffs] master updated (478d9d9 -> b6c6629), Juanma Barranquero, 2015/10/24
- [Emacs-diffs] master 8a48f16 1/5: addpm.c: Don't pass REG_OPTION_NON_VOLATILE to RegOpenKeyEx, Juanma Barranquero, 2015/10/24
- [Emacs-diffs] master 8c5747e 2/5: * nt/addpm.c (add_registry): Do not compute unused return value., Juanma Barranquero, 2015/10/24
- [Emacs-diffs] master b6c6629 5/5: addpm.c: Silence some warnings., Juanma Barranquero, 2015/10/24
- [Emacs-diffs] master cbbea70 3/5: addpm.c: Replace existing entries, but do not create new ones,
Juanma Barranquero <=
- [Emacs-diffs] master 87a3064 4/5: addpm.c: Do not add obsolete GTK libraries to the path., Juanma Barranquero, 2015/10/24