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
518a6c2d
Commit
518a6c2d
authored
Apr 01, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Use C runtime wchar functions instead of wine/unicode.h.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ad21554e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
51 deletions
+50
-51
export.c
programs/reg/export.c
+9
-9
import.c
programs/reg/import.c
+17
-18
reg.c
programs/reg/reg.c
+24
-24
No files found.
programs/reg/export.c
View file @
518a6c2d
...
...
@@ -17,9 +17,9 @@
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <wine/unicode.h>
#include <wine/heap.h>
#include "reg.h"
...
...
@@ -92,7 +92,7 @@ static size_t export_value_name(HANDLE hFile, WCHAR *name, size_t len)
{
WCHAR
*
str
=
escape_string
(
name
,
len
,
&
line_len
);
WCHAR
*
buf
=
heap_xalloc
((
line_len
+
4
)
*
sizeof
(
WCHAR
));
line_len
=
s
printfW
(
buf
,
quoted_fmt
,
str
);
line_len
=
s
wprintf
(
buf
,
quoted_fmt
,
str
);
write_file
(
hFile
,
buf
);
heap_free
(
buf
);
heap_free
(
str
);
...
...
@@ -116,7 +116,7 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size)
len
=
size
/
sizeof
(
WCHAR
)
-
1
;
str
=
escape_string
(
data
,
len
,
&
line_len
);
*
buf
=
heap_xalloc
((
line_len
+
3
)
*
sizeof
(
WCHAR
));
s
printfW
(
*
buf
,
fmt
,
str
);
s
wprintf
(
*
buf
,
fmt
,
str
);
heap_free
(
str
);
}
...
...
@@ -125,7 +125,7 @@ static void export_dword_data(WCHAR **buf, DWORD *data)
static
const
WCHAR
fmt
[]
=
{
'd'
,
'w'
,
'o'
,
'r'
,
'd'
,
':'
,
'%'
,
'0'
,
'8'
,
'x'
,
0
};
*
buf
=
heap_xalloc
(
15
*
sizeof
(
WCHAR
));
s
printfW
(
*
buf
,
fmt
,
*
data
);
s
wprintf
(
*
buf
,
fmt
,
*
data
);
}
static
size_t
export_hex_data_type
(
HANDLE
hFile
,
DWORD
type
)
...
...
@@ -142,7 +142,7 @@ static size_t export_hex_data_type(HANDLE hFile, DWORD type)
else
{
WCHAR
*
buf
=
heap_xalloc
(
15
*
sizeof
(
WCHAR
));
line_len
=
s
printfW
(
buf
,
hexp_fmt
,
type
);
line_len
=
s
wprintf
(
buf
,
hexp_fmt
,
type
);
write_file
(
hFile
,
buf
);
heap_free
(
buf
);
}
...
...
@@ -168,7 +168,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type,
for
(
i
=
0
,
pos
=
0
;
i
<
size
;
i
++
)
{
pos
+=
s
printfW
(
*
buf
+
pos
,
fmt
,
((
BYTE
*
)
data
)[
i
]);
pos
+=
s
wprintf
(
*
buf
+
pos
,
fmt
,
((
BYTE
*
)
data
)[
i
]);
if
(
i
==
num_commas
)
break
;
(
*
buf
)[
pos
++
]
=
','
;
(
*
buf
)[
pos
]
=
0
;
...
...
@@ -233,7 +233,7 @@ static void export_key_name(HANDLE hFile, WCHAR *name)
WCHAR
*
buf
;
buf
=
heap_xalloc
((
lstrlenW
(
name
)
+
7
)
*
sizeof
(
WCHAR
));
s
printfW
(
buf
,
fmt
,
name
);
s
wprintf
(
buf
,
fmt
,
name
);
write_file
(
hFile
,
buf
);
heap_free
(
buf
);
}
...
...
@@ -361,7 +361,7 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file)
static
BOOL
is_overwrite_switch
(
const
WCHAR
*
s
)
{
if
(
strlenW
(
s
)
>
2
)
if
(
l
strlenW
(
s
)
>
2
)
return
FALSE
;
if
((
s
[
0
]
==
'/'
||
s
[
0
]
==
'-'
)
&&
(
s
[
1
]
==
'y'
||
s
[
1
]
==
'Y'
))
...
...
@@ -405,6 +405,6 @@ int reg_export(int argc, WCHAR *argv[])
error:
output_message
(
STRING_INVALID_SYNTAX
);
output_message
(
STRING_FUNC_HELP
,
struprW
(
argv
[
1
]));
output_message
(
STRING_FUNC_HELP
,
wcsupr
(
argv
[
1
]));
return
1
;
}
programs/reg/import.c
View file @
518a6c2d
...
...
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <wine/unicode.h>
#include <wine/debug.h>
#include <wine/heap.h>
...
...
@@ -162,7 +161,7 @@ static BOOL convert_hex_to_dword(WCHAR *str, DWORD *dw)
if
(
!*
str
)
goto
error
;
p
=
str
;
while
(
is
xdigitW
(
*
p
))
while
(
is
wxdigit
(
*
p
))
{
count
++
;
p
++
;
...
...
@@ -174,7 +173,7 @@ static BOOL convert_hex_to_dword(WCHAR *str, DWORD *dw)
if
(
*
p
&&
*
p
!=
';'
)
goto
error
;
*
end
=
0
;
*
dw
=
strtoulW
(
str
,
&
end
,
16
);
*
dw
=
wcstoul
(
str
,
&
end
,
16
);
return
TRUE
;
error:
...
...
@@ -207,7 +206,7 @@ static BOOL convert_hex_csv_to_hex(struct parser *parser, WCHAR **str)
WCHAR
*
end
;
unsigned
long
wc
;
wc
=
strtoulW
(
s
,
&
end
,
16
);
wc
=
wcstoul
(
s
,
&
end
,
16
);
if
(
wc
>
0xff
)
return
FALSE
;
if
(
s
==
end
&&
wc
==
0
)
...
...
@@ -269,7 +268,7 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
for
(
ptr
=
data_types
;
ptr
->
tag
;
ptr
++
)
{
if
(
strncmpW
(
ptr
->
tag
,
*
line
,
ptr
->
len
))
if
(
wcsncmp
(
ptr
->
tag
,
*
line
,
ptr
->
len
))
continue
;
parser
->
parse_type
=
ptr
->
parse_type
;
...
...
@@ -281,7 +280,7 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
WCHAR
*
end
;
DWORD
val
;
if
(
!**
line
||
to
lowerW
((
*
line
)[
1
])
==
'x'
)
if
(
!**
line
||
to
wlower
((
*
line
)[
1
])
==
'x'
)
return
FALSE
;
/* "hex(xx):" is special */
...
...
@@ -354,7 +353,7 @@ static HKEY parse_key_name(WCHAR *key_name, WCHAR **key_path)
{
if
(
!
key_name
)
return
0
;
*
key_path
=
strchrW
(
key_name
,
'\\'
);
*
key_path
=
wcschr
(
key_name
,
'\\'
);
if
(
*
key_path
)
(
*
key_path
)
++
;
return
path_get_rootkey
(
key_name
);
...
...
@@ -458,13 +457,13 @@ static enum reg_versions parse_file_header(const WCHAR *s)
while
(
*
s
==
' '
||
*
s
==
'\t'
)
s
++
;
if
(
!
strcmpW
(
s
,
header_31
))
if
(
!
l
strcmpW
(
s
,
header_31
))
return
REG_VERSION_31
;
if
(
!
strcmpW
(
s
,
header_40
))
if
(
!
l
strcmpW
(
s
,
header_40
))
return
REG_VERSION_40
;
if
(
!
strcmpW
(
s
,
header_50
))
if
(
!
l
strcmpW
(
s
,
header_50
))
return
REG_VERSION_50
;
/* The Windows version accepts registry file headers beginning with "REGEDIT" and ending
...
...
@@ -472,7 +471,7 @@ static enum reg_versions parse_file_header(const WCHAR *s)
* "REGEDIT 4", "REGEDIT9" and "REGEDIT4FOO" are all treated as valid file headers.
* In all such cases, however, the contents of the registry file are not imported.
*/
if
(
!
strncmpW
(
s
,
header_31
,
7
))
/* "REGEDIT" without NUL */
if
(
!
wcsncmp
(
s
,
header_31
,
7
))
/* "REGEDIT" without NUL */
return
REG_VERSION_FUZZY
;
return
REG_VERSION_INVALID
;
...
...
@@ -524,11 +523,11 @@ static WCHAR *parse_win31_line_state(struct parser *parser, WCHAR *pos)
if
(
!
(
line
=
get_line
(
parser
->
file
)))
return
NULL
;
if
(
strncmpW
(
line
,
hkcr
,
ARRAY_SIZE
(
hkcr
)))
if
(
wcsncmp
(
line
,
hkcr
,
ARRAY_SIZE
(
hkcr
)))
return
line
;
/* get key name */
while
(
line
[
key_end
]
&&
!
is
spaceW
(
line
[
key_end
]))
key_end
++
;
while
(
line
[
key_end
]
&&
!
is
wspace
(
line
[
key_end
]))
key_end
++
;
value
=
line
+
key_end
;
while
(
*
value
==
' '
||
*
value
==
'\t'
)
value
++
;
...
...
@@ -590,7 +589,7 @@ static WCHAR *key_name_state(struct parser *parser, WCHAR *pos)
{
WCHAR
*
p
=
pos
,
*
key_end
;
if
(
*
p
==
' '
||
*
p
==
'\t'
||
!
(
key_end
=
strrchrW
(
p
,
']'
)))
if
(
*
p
==
' '
||
*
p
==
'\t'
||
!
(
key_end
=
wcsrchr
(
p
,
']'
)))
goto
done
;
*
key_end
=
0
;
...
...
@@ -675,7 +674,7 @@ static WCHAR *data_start_state(struct parser *parser, WCHAR *pos)
while
(
*
p
==
' '
||
*
p
==
'\t'
)
p
++
;
/* trim trailing whitespace */
len
=
strlenW
(
p
);
len
=
l
strlenW
(
p
);
while
(
len
>
0
&&
(
p
[
len
-
1
]
==
' '
||
p
[
len
-
1
]
==
'\t'
))
len
--
;
p
[
len
]
=
0
;
...
...
@@ -840,7 +839,7 @@ static WCHAR *hex_multiline_state(struct parser *parser, WCHAR *pos)
while
(
*
line
==
' '
||
*
line
==
'\t'
)
line
++
;
if
(
!*
line
||
*
line
==
';'
)
return
line
;
if
(
!
is
xdigitW
(
*
line
))
goto
invalid
;
if
(
!
is
wxdigit
(
*
line
))
goto
invalid
;
set_state
(
parser
,
HEX_DATA
);
return
line
;
...
...
@@ -956,11 +955,11 @@ static WCHAR *get_lineW(FILE *fp)
while
(
next
)
{
static
const
WCHAR
line_endings
[]
=
{
'\r'
,
'\n'
,
0
};
WCHAR
*
p
=
strpbrkW
(
line
,
line_endings
);
WCHAR
*
p
=
wcspbrk
(
line
,
line_endings
);
if
(
!
p
)
{
size_t
len
,
count
;
len
=
strlenW
(
next
);
len
=
l
strlenW
(
next
);
memmove
(
buf
,
next
,
(
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
size
-
len
<
3
)
{
...
...
programs/reg/reg.c
View file @
518a6c2d
...
...
@@ -18,8 +18,8 @@
#include <windows.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <wine/unicode.h>
#include <wine/debug.h>
#include <wine/heap.h>
#include "reg.h"
...
...
@@ -191,7 +191,7 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info)
output_message
(
msgid
,
str
);
output_message
(
STRING_YESNO
);
ReadConsoleW
(
GetStdHandle
(
STD_INPUT_HANDLE
),
answer
,
ARRAY_SIZE
(
answer
),
&
count
,
NULL
);
answer
[
0
]
=
to
upperW
(
answer
[
0
]);
answer
[
0
]
=
to
wupper
(
answer
[
0
]);
if
(
answer
[
0
]
==
Ybuffer
[
0
])
return
TRUE
;
if
(
answer
[
0
]
==
Nbuffer
[
0
])
...
...
@@ -201,9 +201,9 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info)
static
inline
BOOL
path_rootname_cmp
(
const
WCHAR
*
input_path
,
const
WCHAR
*
rootkey_name
)
{
DWORD
length
=
strlenW
(
rootkey_name
);
DWORD
length
=
l
strlenW
(
rootkey_name
);
return
(
!
strncmpiW
(
input_path
,
rootkey_name
,
length
)
&&
return
(
!
wcsnicmp
(
input_path
,
rootkey_name
,
length
)
&&
(
input_path
[
length
]
==
0
||
input_path
[
length
]
==
'\\'
));
}
...
...
@@ -230,7 +230,7 @@ static DWORD wchar_get_type(const WCHAR *type_name)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
type_rels
);
i
++
)
{
if
(
!
strcmpiW
(
type_rels
[
i
].
name
,
type_name
))
if
(
!
_wcsicmp
(
type_rels
[
i
].
name
,
type_name
))
return
type_rels
[
i
].
type
;
}
...
...
@@ -275,7 +275,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
{
LPWSTR
rest
;
unsigned
long
val
;
val
=
wcstoul
(
data
,
&
rest
,
(
to
lowerW
(
data
[
1
])
==
'x'
)
?
16
:
10
);
val
=
wcstoul
(
data
,
&
rest
,
(
to
wlower
(
data
[
1
])
==
'x'
)
?
16
:
10
);
if
(
*
rest
||
data
[
0
]
==
'-'
||
(
val
==
~
0u
&&
errno
==
ERANGE
))
{
output_message
(
STRING_MISSING_INTEGER
);
break
;
...
...
@@ -316,7 +316,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
}
case
REG_MULTI_SZ
:
{
int
i
,
destindex
,
len
=
strlenW
(
data
);
int
i
,
destindex
,
len
=
l
strlenW
(
data
);
WCHAR
*
buffer
=
heap_xalloc
((
len
+
2
)
*
sizeof
(
WCHAR
));
for
(
i
=
0
,
destindex
=
0
;
i
<
len
;
i
++
,
destindex
++
)
...
...
@@ -353,7 +353,7 @@ static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DW
static
BOOL
sane_path
(
const
WCHAR
*
key
)
{
unsigned
int
i
=
strlenW
(
key
);
unsigned
int
i
=
l
strlenW
(
key
);
if
(
i
<
3
||
(
key
[
i
-
1
]
==
'\\'
&&
key
[
i
-
2
]
==
'\\'
))
{
...
...
@@ -528,7 +528,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
case
REG_SZ
:
case
REG_EXPAND_SZ
:
buffer
=
heap_xalloc
(
size_bytes
);
strcpyW
(
buffer
,
(
WCHAR
*
)
src
);
l
strcpyW
(
buffer
,
(
WCHAR
*
)
src
);
break
;
case
REG_NONE
:
case
REG_BINARY
:
...
...
@@ -539,7 +539,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
buffer
=
heap_xalloc
((
size_bytes
*
2
+
1
)
*
sizeof
(
WCHAR
));
ptr
=
buffer
;
for
(
i
=
0
;
i
<
size_bytes
;
i
++
)
ptr
+=
s
printfW
(
ptr
,
fmt
,
src
[
i
]);
ptr
+=
s
wprintf
(
ptr
,
fmt
,
src
[
i
]);
break
;
}
case
REG_DWORD
:
...
...
@@ -550,7 +550,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
static
const
WCHAR
fmt
[]
=
{
'0'
,
'x'
,
'%'
,
'x'
,
0
};
buffer
=
heap_xalloc
((
zero_x_dword
+
1
)
*
sizeof
(
WCHAR
));
s
printfW
(
buffer
,
fmt
,
*
(
DWORD
*
)
src
);
s
wprintf
(
buffer
,
fmt
,
*
(
DWORD
*
)
src
);
break
;
}
case
REG_MULTI_SZ
:
...
...
@@ -635,7 +635,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD
static
const
WCHAR
fmt
[]
=
{
'%'
,
's'
,
'\\'
,
'%'
,
's'
,
0
};
subkey_path
=
heap_xalloc
((
path_len
+
subkey_len
+
2
)
*
sizeof
(
WCHAR
));
s
printfW
(
subkey_path
,
fmt
,
path
,
subkey_name
);
s
wprintf
(
subkey_path
,
fmt
,
path
,
subkey_name
);
return
subkey_path
;
}
...
...
@@ -694,7 +694,7 @@ static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse)
subkey_name
=
heap_xalloc
(
MAX_SUBKEY_LEN
*
sizeof
(
WCHAR
));
path_len
=
strlenW
(
path
);
path_len
=
l
strlenW
(
path
);
i
=
0
;
for
(;;)
...
...
@@ -772,7 +772,7 @@ static int query_all(HKEY key, WCHAR *path, BOOL recurse)
subkey_name
=
heap_xalloc
(
MAX_SUBKEY_LEN
*
sizeof
(
WCHAR
));
path_len
=
strlenW
(
path
);
path_len
=
l
strlenW
(
path
);
i
=
0
;
for
(;;)
...
...
@@ -845,18 +845,18 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path)
break
;
}
len
=
strlenW
(
root_rels
[
i
].
long_name
);
len
=
l
strlenW
(
root_rels
[
i
].
long_name
);
if
(
!
path
)
{
long_key
=
heap_xalloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
strcpyW
(
long_key
,
root_rels
[
i
].
long_name
);
l
strcpyW
(
long_key
,
root_rels
[
i
].
long_name
);
return
long_key
;
}
len
+=
strlenW
(
path
)
+
1
;
/* add one for the backslash */
len
+=
l
strlenW
(
path
)
+
1
;
/* add one for the backslash */
long_key
=
heap_xalloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
s
printfW
(
long_key
,
fmt
,
root_rels
[
i
].
long_name
,
path
);
s
wprintf
(
long_key
,
fmt
,
root_rels
[
i
].
long_name
,
path
);
return
long_key
;
}
...
...
@@ -865,7 +865,7 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long
if
(
!
sane_path
(
key
))
return
FALSE
;
*
path
=
strchrW
(
key
,
'\\'
);
*
path
=
wcschr
(
key
,
'\\'
);
if
(
*
path
)
(
*
path
)
++
;
*
root
=
path_get_rootkey
(
key
);
...
...
@@ -883,10 +883,10 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long
static
BOOL
is_switch
(
const
WCHAR
*
s
,
const
WCHAR
c
)
{
if
(
strlenW
(
s
)
>
2
)
if
(
l
strlenW
(
s
)
>
2
)
return
FALSE
;
if
((
s
[
0
]
==
'/'
||
s
[
0
]
==
'-'
)
&&
(
s
[
1
]
==
c
||
s
[
1
]
==
to
upperW
(
c
)))
if
((
s
[
0
]
==
'/'
||
s
[
0
]
==
'-'
)
&&
(
s
[
1
]
==
c
||
s
[
1
]
==
to
wupper
(
c
)))
return
TRUE
;
return
FALSE
;
...
...
@@ -981,7 +981,7 @@ int wmain(int argc, WCHAR *argvW[])
if
(
argc
==
2
||
((
show_op_help
||
op
==
REG_IMPORT
)
&&
argc
>
3
))
{
output_message
(
STRING_INVALID_SYNTAX
);
output_message
(
STRING_FUNC_HELP
,
struprW
(
argvW
[
1
]));
output_message
(
STRING_FUNC_HELP
,
wcsupr
(
argvW
[
1
]));
return
1
;
}
else
if
(
show_op_help
)
...
...
@@ -1021,7 +1021,7 @@ int wmain(int argc, WCHAR *argvW[])
return
1
;
}
switch
(
to
lowerW
(
argvW
[
i
][
1
]))
switch
(
to
wlower
(
argvW
[
i
][
1
]))
{
case
'v'
:
if
(
value_name
||
!
(
value_name
=
argvW
[
++
i
]))
...
...
@@ -1052,7 +1052,7 @@ int wmain(int argc, WCHAR *argvW[])
}
ptr
=
argvW
[
++
i
];
if
(
!
ptr
||
strlenW
(
ptr
)
!=
1
)
if
(
!
ptr
||
l
strlenW
(
ptr
)
!=
1
)
{
output_message
(
STRING_INVALID_CMDLINE
);
return
1
;
...
...
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