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
7df72225
Commit
7df72225
authored
Nov 12, 2008
by
Francois Gouget
Committed by
Alexandre Julliard
Nov 12, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Simplify / clean up export_hkey().
Avoid unneeded/redundant calls to lstrcatW() and lstrlenW(). Tighten the scope of variables.
parent
126ffb1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
33 deletions
+29
-33
regproc.c
programs/regedit/regproc.c
+29
-33
No files found.
programs/regedit/regproc.c
View file @
7df72225
...
...
@@ -972,7 +972,6 @@ static void export_hkey(FILE *file, HKEY key,
BOOL
more_data
;
LONG
ret
;
WCHAR
key_format
[]
=
{
'\n'
,
'['
,
'%'
,
's'
,
']'
,
'\n'
,
0
};
DWORD
line_pos
;
/* get size information and resize the buffers if necessary */
if
(
RegQueryInfoKeyW
(
key
,
NULL
,
NULL
,
NULL
,
NULL
,
...
...
@@ -1005,7 +1004,6 @@ static void export_hkey(FILE *file, HKEY key,
DWORD
value_type
;
DWORD
val_name_size1
=
*
val_name_size
;
DWORD
val_size1
=
*
val_size
;
DWORD
line_len
=
0
;
ret
=
RegEnumValueW
(
key
,
i
,
*
val_name_buf
,
&
val_name_size1
,
NULL
,
&
value_type
,
*
val_buf
,
&
val_size1
);
if
(
ret
!=
ERROR_SUCCESS
)
{
...
...
@@ -1014,17 +1012,18 @@ static void export_hkey(FILE *file, HKEY key,
REGPROC_print_error
();
}
}
else
{
DWORD
line_len
;
i
++
;
if
((
*
val_name_buf
)[
0
])
{
const
WCHAR
val_start
[]
=
{
'"'
,
'%'
,
's'
,
'"'
,
'='
,
0
};
line_
pos
=
line_
len
=
3
+
lstrlenW
(
*
val_name_buf
);
line_len
=
3
+
lstrlenW
(
*
val_name_buf
);
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
wsprintfW
(
*
line_buf
,
val_start
,
*
val_name_buf
);
}
else
{
const
WCHAR
std_val
[]
=
{
'@'
,
'='
,
0
};
line_
pos
=
line_
len
=
2
;
line_len
=
2
;
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
lstrcpyW
(
*
line_buf
,
std_val
);
}
...
...
@@ -1035,16 +1034,18 @@ static void export_hkey(FILE *file, HKEY key,
{
const
WCHAR
start
[]
=
{
'"'
,
0
};
const
WCHAR
end
[]
=
{
'"'
,
'\n'
,
0
};
DWORD
len
;
line_len
+=
lstrlenW
(
start
);
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
lstrcatW
(
*
line_buf
,
start
);
len
=
lstrlenW
(
start
);
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
+
len
);
lstrcpyW
(
*
line_buf
+
line_len
,
start
);
line_len
+=
len
;
if
(
val_size1
)
REGPROC_export_string
(
line_buf
,
line_buf_size
,
&
line_len
,
(
WCHAR
*
)
*
val_buf
);
if
(
val_size1
)
REGPROC_export_string
(
line_buf
,
line_buf_size
,
&
line_len
,
(
WCHAR
*
)
*
val_buf
);
line_len
+=
lstrlenW
(
end
);
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
lstrcatW
(
*
line_buf
,
end
);
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
+
lstrlenW
(
end
));
lstrcpyW
(
*
line_buf
+
line_len
,
end
);
break
;
}
...
...
@@ -1052,9 +1053,8 @@ static void export_hkey(FILE *file, HKEY key,
{
WCHAR
format
[]
=
{
'd'
,
'w'
,
'o'
,
'r'
,
'd'
,
':'
,
'%'
,
'0'
,
'8'
,
'x'
,
'\n'
,
0
};
line_len
+=
15
;
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
wsprintfW
(
*
line_buf
+
line_pos
,
format
,
*
((
DWORD
*
)
*
val_buf
));
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
+
15
);
wsprintfW
(
*
line_buf
+
line_len
,
format
,
*
((
DWORD
*
)
*
val_buf
));
break
;
}
...
...
@@ -1077,9 +1077,8 @@ static void export_hkey(FILE *file, HKEY key,
DWORD
i1
;
const
WCHAR
*
hex_prefix
;
WCHAR
buf
[
20
];
int
cur_pos
;
int
hex_pos
,
data_pos
,
column
;
const
WCHAR
hex
[]
=
{
'h'
,
'e'
,
'x'
,
':'
,
0
};
const
WCHAR
delim
[]
=
{
'"'
,
'"'
,
'='
,
0
};
const
WCHAR
format
[]
=
{
'%'
,
'0'
,
'2'
,
'x'
,
0
};
const
WCHAR
comma
[]
=
{
','
,
0
};
const
WCHAR
concat
[]
=
{
'\\'
,
'\n'
,
' '
,
' '
,
0
};
...
...
@@ -1097,35 +1096,32 @@ static void export_hkey(FILE *file, HKEY key,
val_buf1
=
(
BYTE
*
)
GetMultiByteStringN
((
WCHAR
*
)
*
val_buf
,
val_size1
/
sizeof
(
WCHAR
),
&
val_buf1_size
);
}
/* position of where the next character will be printed */
/* NOTE: yes, strlen("hex:") is used even for hex(x): */
cur_pos
=
lstrlenW
(
delim
)
+
lstrlenW
(
hex
)
+
lstrlenW
(
*
val_name_buf
);
hex_pos
=
line_len
;
line_len
+=
lstrlenW
(
hex_prefix
);
data_pos
=
line_len
;
line_len
+=
val_buf1_size
*
3
+
lstrlenW
(
concat
)
*
((
int
)((
float
)
val_buf1_size
*
3
.
0
/
(
float
)
REG_FILE_HEX_LINE_LEN
)
+
1
)
+
1
;
REGPROC_resize_char_buffer
(
line_buf
,
line_buf_size
,
line_len
);
lstrc
atW
(
*
line_buf
,
hex_prefix
);
line_pos
+=
lstrlenW
(
hex_prefix
);
lstrc
pyW
(
*
line_buf
+
hex_pos
,
hex_prefix
);
column
=
data_pos
;
/* no line wrap yet */
for
(
i1
=
0
;
i1
<
val_buf1_size
;
i1
++
)
{
wsprintfW
(
*
line_buf
+
line
_pos
,
format
,
(
unsigned
int
)(
val_buf1
)[
i1
]);
line
_pos
+=
2
;
wsprintfW
(
*
line_buf
+
data
_pos
,
format
,
(
unsigned
int
)(
val_buf1
)[
i1
]);
data
_pos
+=
2
;
if
(
i1
+
1
<
val_buf1_size
)
{
lstrcpyW
(
*
line_buf
+
line
_pos
,
comma
);
line
_pos
++
;
lstrcpyW
(
*
line_buf
+
data
_pos
,
comma
);
data
_pos
++
;
}
c
ur_pos
+=
3
;
c
olumn
+=
3
;
/* wrap the line */
if
(
c
ur_pos
>
REG_FILE_HEX_LINE_LEN
)
{
lstrcpyW
(
*
line_buf
+
line
_pos
,
concat
);
line
_pos
+=
lstrlenW
(
concat
);
c
ur_pos
=
2
;
if
(
c
olumn
>
REG_FILE_HEX_LINE_LEN
)
{
lstrcpyW
(
*
line_buf
+
data
_pos
,
concat
);
data
_pos
+=
lstrlenW
(
concat
);
c
olumn
=
2
;
}
}
lstrcpyW
(
*
line_buf
+
data_pos
,
newline
);
if
(
value_type
==
REG_MULTI_SZ
&&
!
unicode
)
HeapFree
(
GetProcessHeap
(),
0
,
val_buf1
);
lstrcpyW
(
*
line_buf
+
line_pos
,
newline
);
break
;
}
}
...
...
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