Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
20e5b9e8
Commit
20e5b9e8
authored
May 21, 2018
by
Hugh McMaster
Committed by
Alexandre Julliard
May 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Simplify boolean comparisons in edit.c.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
b24ee836
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
edit.c
programs/regedit/edit.c
+20
-20
No files found.
programs/regedit/edit.c
View file @
20e5b9e8
...
@@ -197,7 +197,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
...
@@ -197,7 +197,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
WCHAR
empty
=
0
;
WCHAR
empty
=
0
;
lRet
=
RegQueryValueExW
(
hKey
,
valueName
?
valueName
:
&
empty
,
0
,
lpType
,
0
,
&
valueDataLen
);
lRet
=
RegQueryValueExW
(
hKey
,
valueName
?
valueName
:
&
empty
,
0
,
lpType
,
0
,
&
valueDataLen
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
if
(
lRet
==
ERROR_FILE_NOT_FOUND
&&
!
valueName
)
{
/* no default value here, make it up */
if
(
lRet
==
ERROR_FILE_NOT_FOUND
&&
!
valueName
)
{
/* no default value here, make it up */
if
(
len
)
*
len
=
1
;
if
(
len
)
*
len
=
1
;
if
(
lpType
)
*
lpType
=
REG_SZ
;
if
(
lpType
)
*
lpType
=
REG_SZ
;
...
@@ -211,7 +211,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
...
@@ -211,7 +211,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
if
(
*
lpType
==
REG_DWORD
)
valueDataLen
=
sizeof
(
DWORD
);
if
(
*
lpType
==
REG_DWORD
)
valueDataLen
=
sizeof
(
DWORD
);
buffer
=
heap_xalloc
(
valueDataLen
+
sizeof
(
WCHAR
));
buffer
=
heap_xalloc
(
valueDataLen
+
sizeof
(
WCHAR
));
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
0
,
0
,
(
LPBYTE
)
buffer
,
&
valueDataLen
);
lRet
=
RegQueryValueExW
(
hKey
,
valueName
,
0
,
0
,
(
LPBYTE
)
buffer
,
&
valueDataLen
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
goto
done
;
goto
done
;
}
}
...
@@ -235,7 +235,7 @@ BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
...
@@ -235,7 +235,7 @@ BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
HKEY
hKey
;
HKEY
hKey
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_CREATE_SUB_KEY
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_CREATE_SUB_KEY
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_CREATE_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_CREATE_KEY_FAILED
);
goto
done
;
goto
done
;
}
}
...
@@ -246,13 +246,13 @@ BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
...
@@ -246,13 +246,13 @@ BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPWSTR keyName)
for
(
keyNum
=
1
;
keyNum
<
100
;
keyNum
++
)
{
for
(
keyNum
=
1
;
keyNum
<
100
;
keyNum
++
)
{
wsprintfW
(
keyName
,
newKey
,
keyNum
);
wsprintfW
(
keyName
,
newKey
,
keyNum
);
lRet
=
RegOpenKeyW
(
hKey
,
keyName
,
&
retKey
);
lRet
=
RegOpenKeyW
(
hKey
,
keyName
,
&
retKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
break
;
if
(
lRet
)
break
;
RegCloseKey
(
retKey
);
RegCloseKey
(
retKey
);
}
}
if
(
lRet
==
ERROR_SUCCESS
)
goto
done
;
if
(
lRet
==
ERROR_SUCCESS
)
goto
done
;
lRet
=
RegCreateKeyW
(
hKey
,
keyName
,
&
retKey
);
lRet
=
RegCreateKeyW
(
hKey
,
keyName
,
&
retKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_CREATE_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_CREATE_KEY_FAILED
);
goto
done
;
goto
done
;
}
}
...
@@ -273,7 +273,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
...
@@ -273,7 +273,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
LONG
len
;
LONG
len
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_SET_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_SET_VALUE_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -389,7 +389,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
...
@@ -389,7 +389,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
HKEY
hKey
;
HKEY
hKey
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_DELETE_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_DELETE_KEY_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -399,7 +399,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
...
@@ -399,7 +399,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
goto
done
;
goto
done
;
lRet
=
SHDeleteKeyW
(
hKeyRoot
,
keyPath
);
lRet
=
SHDeleteKeyW
(
hKeyRoot
,
keyPath
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_BAD_KEY
,
keyPath
);
error_code_messagebox
(
hwnd
,
IDS_BAD_KEY
,
keyPath
);
goto
done
;
goto
done
;
}
}
...
@@ -419,7 +419,7 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, B
...
@@ -419,7 +419,7 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, B
WCHAR
empty
=
0
;
WCHAR
empty
=
0
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
return
FALSE
;
if
(
lRet
)
return
FALSE
;
if
(
showMessageBox
)
if
(
showMessageBox
)
{
{
...
@@ -429,10 +429,10 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, B
...
@@ -429,10 +429,10 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, B
}
}
lRet
=
RegDeleteValueW
(
hKey
,
valueName
?
valueName
:
&
empty
);
lRet
=
RegDeleteValueW
(
hKey
,
valueName
?
valueName
:
&
empty
);
if
(
lRet
!=
ERROR_SUCCESS
&&
valueName
)
{
if
(
lRet
&&
valueName
)
{
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
error_code_messagebox
(
hwnd
,
IDS_BAD_VALUE
,
valueName
);
}
}
if
(
lRet
!=
ERROR_SUCCESS
)
goto
done
;
if
(
lRet
)
goto
done
;
result
=
TRUE
;
result
=
TRUE
;
done:
done:
...
@@ -451,7 +451,7 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
...
@@ -451,7 +451,7 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
LVITEMW
item
;
LVITEMW
item
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_CREATE_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_CREATE_VALUE_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -470,7 +470,7 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
...
@@ -470,7 +470,7 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
}
}
lRet
=
RegSetValueExW
(
hKey
,
valueName
,
0
,
valueType
,
(
BYTE
*
)
&
valueDword
,
sizeof
(
DWORD
));
lRet
=
RegSetValueExW
(
hKey
,
valueName
,
0
,
valueType
,
(
BYTE
*
)
&
valueDword
,
sizeof
(
DWORD
));
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_CREATE_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_CREATE_VALUE_FAILED
);
goto
done
;
goto
done
;
}
}
...
@@ -501,7 +501,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
...
@@ -501,7 +501,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
if
(
!
newName
)
return
FALSE
;
if
(
!
newName
)
return
FALSE
;
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
lRet
=
RegOpenKeyExW
(
hKeyRoot
,
keyPath
,
0
,
KEY_READ
|
KEY_SET_VALUE
,
&
hKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -513,12 +513,12 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
...
@@ -513,12 +513,12 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
value
=
read_value
(
hwnd
,
hKey
,
oldName
,
&
type
,
&
len
);
value
=
read_value
(
hwnd
,
hKey
,
oldName
,
&
type
,
&
len
);
if
(
!
value
)
goto
done
;
if
(
!
value
)
goto
done
;
lRet
=
RegSetValueExW
(
hKey
,
newName
,
0
,
type
,
(
BYTE
*
)
value
,
len
);
lRet
=
RegSetValueExW
(
hKey
,
newName
,
0
,
type
,
(
BYTE
*
)
value
,
len
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
goto
done
;
goto
done
;
}
}
lRet
=
RegDeleteValueW
(
hKey
,
oldName
);
lRet
=
RegDeleteValueW
(
hKey
,
oldName
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
RegDeleteValueW
(
hKey
,
newName
);
RegDeleteValueW
(
hKey
,
newName
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_VALUE_FAILED
);
goto
done
;
goto
done
;
...
@@ -556,7 +556,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
...
@@ -556,7 +556,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
*
srcSubKey_copy
=
0
;
*
srcSubKey_copy
=
0
;
srcSubKey
=
srcSubKey_copy
+
1
;
srcSubKey
=
srcSubKey_copy
+
1
;
lRet
=
RegOpenKeyExW
(
hRootKey
,
parentPath
,
0
,
KEY_READ
|
KEY_CREATE_SUB_KEY
,
&
parentKey
);
lRet
=
RegOpenKeyExW
(
hRootKey
,
parentPath
,
0
,
KEY_READ
|
KEY_CREATE_SUB_KEY
,
&
parentKey
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
goto
done
;
goto
done
;
}
}
...
@@ -569,14 +569,14 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
...
@@ -569,14 +569,14 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
KEY_WRITE
,
NULL
/* FIXME */
,
&
destKey
,
&
disposition
);
KEY_WRITE
,
NULL
/* FIXME */
,
&
destKey
,
&
disposition
);
if
(
disposition
==
REG_OPENED_EXISTING_KEY
)
if
(
disposition
==
REG_OPENED_EXISTING_KEY
)
lRet
=
ERROR_FILE_EXISTS
;
lRet
=
ERROR_FILE_EXISTS
;
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_KEY_EXISTS
,
srcSubKey
);
error_code_messagebox
(
hwnd
,
IDS_KEY_EXISTS
,
srcSubKey
);
goto
done
;
goto
done
;
}
}
/* FIXME: SHCopyKey does not copy the security attributes */
/* FIXME: SHCopyKey does not copy the security attributes */
lRet
=
SHCopyKeyW
(
parentKey
,
srcSubKey
,
destKey
,
0
);
lRet
=
SHCopyKeyW
(
parentKey
,
srcSubKey
,
destKey
,
0
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
RegCloseKey
(
destKey
);
RegCloseKey
(
destKey
);
RegDeleteKeyW
(
parentKey
,
newName
);
RegDeleteKeyW
(
parentKey
,
newName
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
...
@@ -584,7 +584,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
...
@@ -584,7 +584,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
}
}
lRet
=
SHDeleteKeyW
(
hRootKey
,
keyPath
);
lRet
=
SHDeleteKeyW
(
hRootKey
,
keyPath
);
if
(
lRet
!=
ERROR_SUCCESS
)
{
if
(
lRet
)
{
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
error_code_messagebox
(
hwnd
,
IDS_RENAME_KEY_FAILED
);
goto
done
;
goto
done
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment