Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
9b01eda7
Commit
9b01eda7
authored
Feb 11, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use external codepage tables for the Unix codepage too.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fb316c33
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
94 deletions
+136
-94
directory.c
dlls/ntdll/directory.c
+22
-35
env.c
dlls/ntdll/env.c
+8
-11
file.c
dlls/ntdll/file.c
+1
-1
locale.c
dlls/ntdll/locale.c
+87
-22
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+2
-3
path.c
dlls/ntdll/path.c
+11
-17
process.c
dlls/ntdll/process.c
+5
-5
No files found.
dlls/ntdll/directory.c
View file @
9b01eda7
...
...
@@ -1451,8 +1451,8 @@ static BOOL append_entry( struct dir_data *data, const char *long_name,
WCHAR
short_nameW
[
13
];
UNICODE_STRING
str
;
long_len
=
ntdll_umbstowcs
(
0
,
long_name
,
strlen
(
long_name
),
long_nameW
,
MAX_DIR_ENTRY_LEN
);
if
(
long_len
==
-
1
)
return
TRUE
;
long_len
=
ntdll_umbstowcs
(
long_name
,
strlen
(
long_name
),
long_nameW
,
ARRAY_SIZE
(
long_nameW
)
);
if
(
long_len
==
ARRAY_SIZE
(
long_nameW
)
)
return
TRUE
;
long_nameW
[
long_len
]
=
0
;
str
.
Buffer
=
long_nameW
;
...
...
@@ -1461,9 +1461,8 @@ static BOOL append_entry( struct dir_data *data, const char *long_name,
if
(
short_name
)
{
short_len
=
ntdll_umbstowcs
(
0
,
short_name
,
strlen
(
short_name
),
short_len
=
ntdll_umbstowcs
(
short_name
,
strlen
(
short_name
),
short_nameW
,
ARRAY_SIZE
(
short_nameW
)
-
1
);
if
(
short_len
==
-
1
)
short_len
=
ARRAY_SIZE
(
short_nameW
)
-
1
;
for
(
i
=
0
;
i
<
short_len
;
i
++
)
short_nameW
[
i
]
=
toupperW
(
short_nameW
[
i
]
);
}
else
/* generate a short name if necessary */
...
...
@@ -1795,12 +1794,10 @@ static NTSTATUS read_directory_data( struct dir_data *data, int fd, const UNICOD
if
(
!
has_wildcard
(
mask
))
{
/* convert the mask to a Unix name and check for it */
int
ret
,
used_default
;
char
unix_name
[
MAX_DIR_ENTRY_LEN
*
3
+
1
];
ret
=
ntdll_wcstoumbs
(
0
,
mask
->
Buffer
,
mask
->
Length
/
sizeof
(
WCHAR
),
unix_name
,
sizeof
(
unix_name
)
-
1
,
NULL
,
&
used_default
);
if
(
ret
>
0
&&
!
used_default
)
int
ret
=
ntdll_wcstoumbs
(
mask
->
Buffer
,
mask
->
Length
/
sizeof
(
WCHAR
),
unix_name
,
sizeof
(
unix_name
)
-
1
,
TRUE
);
if
(
ret
>
0
)
{
unix_name
[
ret
]
=
0
;
#ifdef HAVE_GETATTRLIST
...
...
@@ -2047,16 +2044,13 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
DIR
*
dir
;
struct
dirent
*
de
;
struct
stat
st
;
int
ret
,
used_default
;
int
ret
;
/* try a shortcut for this directory */
unix_name
[
pos
++
]
=
'/'
;
ret
=
ntdll_wcstoumbs
(
0
,
name
,
length
,
unix_name
+
pos
,
MAX_DIR_ENTRY_LEN
,
NULL
,
&
used_default
);
/* if we used the default char, the Unix name won't round trip properly back to Unicode */
/* so it cannot match the file we are looking for */
if
(
ret
>=
0
&&
!
used_default
)
ret
=
ntdll_wcstoumbs
(
name
,
length
,
unix_name
+
pos
,
MAX_DIR_ENTRY_LEN
+
1
,
TRUE
);
if
(
ret
>=
0
&&
ret
<=
MAX_DIR_ENTRY_LEN
)
{
unix_name
[
pos
+
ret
]
=
0
;
if
(
!
stat
(
unix_name
,
&
st
))
...
...
@@ -2106,7 +2100,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
if
(
kde
[
1
].
d_name
[
0
])
{
ret
=
ntdll_umbstowcs
(
0
,
kde
[
1
].
d_name
,
strlen
(
kde
[
1
].
d_name
),
ret
=
ntdll_umbstowcs
(
kde
[
1
].
d_name
,
strlen
(
kde
[
1
].
d_name
),
buffer
,
MAX_DIR_ENTRY_LEN
);
if
(
ret
==
length
&&
!
strncmpiW
(
buffer
,
name
,
length
))
{
...
...
@@ -2116,7 +2110,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
goto
success
;
}
}
ret
=
ntdll_umbstowcs
(
0
,
kde
[
0
].
d_name
,
strlen
(
kde
[
0
].
d_name
),
ret
=
ntdll_umbstowcs
(
kde
[
0
].
d_name
,
strlen
(
kde
[
0
].
d_name
),
buffer
,
MAX_DIR_ENTRY_LEN
);
if
(
ret
==
length
&&
!
strncmpiW
(
buffer
,
name
,
length
))
{
...
...
@@ -2151,7 +2145,7 @@ static NTSTATUS find_file_in_dir( char *unix_name, int pos, const WCHAR *name, i
str
.
MaximumLength
=
sizeof
(
buffer
);
while
((
de
=
readdir
(
dir
)))
{
ret
=
ntdll_umbstowcs
(
0
,
de
->
d_name
,
strlen
(
de
->
d_name
),
buffer
,
MAX_DIR_ENTRY_LEN
);
ret
=
ntdll_umbstowcs
(
de
->
d_name
,
strlen
(
de
->
d_name
),
buffer
,
MAX_DIR_ENTRY_LEN
);
if
(
ret
==
length
&&
!
strncmpiW
(
buffer
,
name
,
length
))
{
strcpy
(
unix_name
+
pos
,
de
->
d_name
);
...
...
@@ -2564,7 +2558,7 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
UINT
disposition
,
BOOLEAN
check_case
)
{
NTSTATUS
status
;
int
ret
,
used_default
,
len
;
int
ret
,
len
;
struct
stat
st
;
char
*
unix_name
=
*
buffer
;
const
BOOL
redirect
=
nb_redirects
&&
ntdll_get_thread_data
()
->
wow64_redir
;
...
...
@@ -2578,10 +2572,8 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
}
unix_name
[
pos
]
=
'/'
;
ret
=
ntdll_wcstoumbs
(
0
,
name
,
name_len
,
unix_name
+
pos
+
1
,
unix_len
-
pos
-
2
,
NULL
,
&
used_default
);
if
(
ret
>=
0
&&
!
used_default
)
/* if we used the default char the name didn't convert properly */
ret
=
ntdll_wcstoumbs
(
name
,
name_len
,
unix_name
+
pos
+
1
,
unix_len
-
pos
-
1
,
TRUE
);
if
(
ret
>=
0
&&
ret
<
unix_len
-
pos
-
1
)
{
char
*
p
;
unix_name
[
pos
+
1
+
ret
]
=
0
;
...
...
@@ -2637,9 +2629,8 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
status
=
STATUS_OBJECT_NAME_NOT_FOUND
;
if
(
disposition
!=
FILE_OPEN
&&
disposition
!=
FILE_OVERWRITE
)
{
ret
=
ntdll_wcstoumbs
(
0
,
name
,
end
-
name
,
unix_name
+
pos
+
1
,
MAX_DIR_ENTRY_LEN
,
NULL
,
&
used_default
);
if
(
ret
>
0
&&
!
used_default
)
ret
=
ntdll_wcstoumbs
(
name
,
end
-
name
,
unix_name
+
pos
+
1
,
MAX_DIR_ENTRY_LEN
+
1
,
TRUE
);
if
(
ret
>
0
&&
ret
<=
MAX_DIR_ENTRY_LEN
)
{
unix_name
[
pos
]
=
'/'
;
unix_name
[
pos
+
1
+
ret
]
=
0
;
...
...
@@ -2699,8 +2690,7 @@ NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_STRING *
for
(
p
=
name
;
p
<
name
+
name_len
;
p
++
)
if
(
*
p
<
32
||
strchrW
(
invalid_charsW
,
*
p
))
return
STATUS_OBJECT_NAME_INVALID
;
unix_len
=
ntdll_wcstoumbs
(
0
,
name
,
name_len
,
NULL
,
0
,
NULL
,
NULL
);
unix_len
+=
MAX_DIR_ENTRY_LEN
+
3
;
unix_len
=
name_len
*
3
+
MAX_DIR_ENTRY_LEN
+
3
;
if
(
!
(
unix_name
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
unix_len
)))
return
STATUS_NO_MEMORY
;
unix_name
[
0
]
=
'.'
;
...
...
@@ -2765,7 +2755,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
const
WCHAR
*
name
,
*
p
;
struct
stat
st
;
char
*
unix_name
;
int
pos
,
ret
,
name_len
,
unix_len
,
prefix_len
,
used_default
;
int
pos
,
ret
,
name_len
,
unix_len
,
prefix_len
;
WCHAR
prefix
[
MAX_DIR_ENTRY_LEN
];
BOOLEAN
is_unix
=
FALSE
;
...
...
@@ -2815,9 +2805,7 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
if
(
*
p
<
32
||
strchrW
(
invalid_charsW
,
*
p
))
return
STATUS_OBJECT_NAME_INVALID
;
}
unix_len
=
ntdll_wcstoumbs
(
0
,
prefix
,
prefix_len
,
NULL
,
0
,
NULL
,
NULL
);
unix_len
+=
ntdll_wcstoumbs
(
0
,
name
,
name_len
,
NULL
,
0
,
NULL
,
NULL
);
unix_len
+=
MAX_DIR_ENTRY_LEN
+
3
;
unix_len
=
(
prefix_len
+
name_len
)
*
3
+
MAX_DIR_ENTRY_LEN
+
3
;
unix_len
+=
strlen
(
config_dir
)
+
sizeof
(
"/dosdevices/"
);
if
(
!
(
unix_name
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
unix_len
)))
return
STATUS_NO_MEMORY
;
...
...
@@ -2825,9 +2813,8 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, ANSI_STRI
strcat
(
unix_name
,
"/dosdevices/"
);
pos
=
strlen
(
unix_name
);
ret
=
ntdll_wcstoumbs
(
0
,
prefix
,
prefix_len
,
unix_name
+
pos
,
unix_len
-
pos
-
1
,
NULL
,
&
used_default
);
if
(
!
ret
||
used_default
)
ret
=
ntdll_wcstoumbs
(
prefix
,
prefix_len
,
unix_name
+
pos
,
unix_len
-
pos
-
1
,
TRUE
);
if
(
ret
<=
0
)
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
unix_name
);
return
STATUS_OBJECT_NAME_INVALID
;
...
...
dlls/ntdll/env.c
View file @
9b01eda7
...
...
@@ -478,7 +478,7 @@ static WCHAR *build_initial_environment( char **env )
for
(
e
=
env
;
*
e
;
e
++
)
{
if
(
is_special_env_var
(
*
e
))
continue
;
size
+=
ntdll_umbstowcs
(
0
,
*
e
,
strlen
(
*
e
)
+
1
,
NULL
,
0
)
;
size
+=
strlen
(
*
e
)
+
1
;
}
if
(
!
(
ptr
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
)
)))
return
NULL
;
...
...
@@ -498,7 +498,7 @@ static WCHAR *build_initial_environment( char **env )
}
else
if
(
is_special_env_var
(
str
))
continue
;
/* skip it */
ntdll_umbstowcs
(
0
,
str
,
strlen
(
str
)
+
1
,
p
,
size
-
(
p
-
ptr
)
);
ntdll_umbstowcs
(
str
,
strlen
(
str
)
+
1
,
p
,
size
-
(
p
-
ptr
)
);
p
+=
strlenW
(
p
)
+
1
;
}
*
p
=
0
;
...
...
@@ -522,9 +522,8 @@ char **build_envp( const WCHAR *envW )
unsigned
int
i
;
lenW
=
get_env_length
(
envW
);
length
=
ntdll_wcstoumbs
(
0
,
envW
,
lenW
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
env
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
length
)))
return
NULL
;
ntdll_wcstoumbs
(
0
,
envW
,
lenW
,
env
,
length
,
NULL
,
NULL
);
if
(
!
(
env
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
lenW
*
3
)))
return
NULL
;
length
=
ntdll_wcstoumbs
(
envW
,
lenW
,
env
,
lenW
*
3
,
FALSE
);
for
(
p
=
env
;
*
p
;
p
+=
strlen
(
p
)
+
1
,
count
++
)
if
(
is_special_env_var
(
p
))
length
+=
4
;
/* prefix it with "WINE" */
...
...
@@ -676,11 +675,10 @@ static void get_image_path( const char *argv0, UNICODE_STRING *path )
{
static
const
WCHAR
exeW
[]
=
{
'.'
,
'e'
,
'x'
,
'e'
,
0
};
WCHAR
*
load_path
,
*
file_part
,
*
name
,
full_name
[
MAX_PATH
];
DWORD
len
;
DWORD
len
=
strlen
(
argv0
)
+
1
;
len
=
ntdll_umbstowcs
(
0
,
argv0
,
strlen
(
argv0
)
+
1
,
NULL
,
0
);
if
(
!
(
name
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
goto
failed
;
ntdll_umbstowcs
(
0
,
argv0
,
strlen
(
argv0
)
+
1
,
name
,
len
);
ntdll_umbstowcs
(
argv0
,
len
,
name
,
len
);
if
(
RtlDetermineDosPathNameType_U
(
name
)
!=
RELATIVE_PATH
||
strchrW
(
name
,
'/'
)
||
strchrW
(
name
,
'\\'
))
...
...
@@ -739,8 +737,7 @@ static void set_library_wargv( char **argv, const UNICODE_STRING *image )
DWORD
total
=
0
;
if
(
image
)
total
+=
1
+
image
->
Length
/
sizeof
(
WCHAR
);
for
(
argc
=
(
image
!=
NULL
);
argv
[
argc
];
argc
++
)
total
+=
ntdll_umbstowcs
(
0
,
argv
[
argc
],
strlen
(
argv
[
argc
])
+
1
,
NULL
,
0
);
for
(
argc
=
(
image
!=
NULL
);
argv
[
argc
];
argc
++
)
total
+=
strlen
(
argv
[
argc
])
+
1
;
wargv
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
total
*
sizeof
(
WCHAR
)
+
(
argc
+
1
)
*
sizeof
(
*
wargv
)
);
...
...
@@ -754,7 +751,7 @@ static void set_library_wargv( char **argv, const UNICODE_STRING *image )
}
for
(
argc
=
(
image
!=
NULL
);
argv
[
argc
];
argc
++
)
{
DWORD
reslen
=
ntdll_umbstowcs
(
0
,
argv
[
argc
],
strlen
(
argv
[
argc
])
+
1
,
p
,
total
);
DWORD
reslen
=
ntdll_umbstowcs
(
argv
[
argc
],
strlen
(
argv
[
argc
])
+
1
,
p
,
total
);
wargv
[
argc
]
=
p
;
p
+=
reslen
;
total
-=
reslen
;
...
...
dlls/ntdll/file.c
View file @
9b01eda7
...
...
@@ -1773,7 +1773,7 @@ static NTSTATUS read_changes_apc( void *user, IO_STATUS_BLOCK *iosb, NTSTATUS st
if
(
event
->
name
[
i
]
==
'/'
)
event
->
name
[
i
]
=
'\\'
;
pfni
->
Action
=
event
->
action
;
pfni
->
FileNameLength
=
ntdll_umbstowcs
(
0
,
event
->
name
,
event
->
len
,
pfni
->
FileName
,
pfni
->
FileNameLength
=
ntdll_umbstowcs
(
event
->
name
,
event
->
len
,
pfni
->
FileName
,
(
left
-
offsetof
(
FILE_NOTIFY_INFORMATION
,
FileName
))
/
sizeof
(
WCHAR
));
last_entry_offset
=
&
pfni
->
NextEntryOffset
;
...
...
dlls/ntdll/locale.c
View file @
9b01eda7
...
...
@@ -35,6 +35,7 @@
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "ntdll_misc.h"
#include "wine/library.h"
#include "wine/unicode.h"
#include "wine/debug.h"
...
...
@@ -80,7 +81,7 @@ LCID user_lcid = 0, system_lcid = 0;
static
LANGID
user_ui_language
,
system_ui_language
;
static
NLSTABLEINFO
nls_info
;
static
HMODULE
kernel32_handle
;
static
const
union
cptable
*
unix_table
;
/* NULL if UTF8 */
static
CPTABLEINFO
unix_table
;
extern
WCHAR
wine_compose
(
const
WCHAR
*
str
)
DECLSPEC_HIDDEN
;
extern
const
unsigned
short
combining_class_table
[]
DECLSPEC_HIDDEN
;
...
...
@@ -498,6 +499,37 @@ static const struct { const char *name; UINT cp; } charset_names[] =
{
"UTF8"
,
CP_UTF8
}
};
static
void
load_unix_cptable
(
unsigned
int
cp
)
{
const
char
*
build_dir
=
wine_get_build_dir
();
const
char
*
data_dir
=
wine_get_data_dir
();
const
char
*
dir
=
build_dir
?
build_dir
:
data_dir
;
struct
stat
st
;
char
*
name
;
USHORT
*
data
;
int
fd
;
if
(
!
(
name
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
strlen
(
dir
)
+
22
)))
return
;
sprintf
(
name
,
"%s/nls/c_%03u.nls"
,
dir
,
cp
);
if
((
fd
=
open
(
name
,
O_RDONLY
))
!=
-
1
)
{
fstat
(
fd
,
&
st
);
if
((
data
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
st
.
st_size
))
&&
st
.
st_size
>
0x10000
&&
read
(
fd
,
data
,
st
.
st_size
)
==
st
.
st_size
)
{
RtlInitCodePageTable
(
data
,
&
unix_table
);
}
else
{
RtlFreeHeap
(
GetProcessHeap
(),
0
,
data
);
}
close
(
fd
);
}
else
ERR
(
"failed to load %s
\n
"
,
debugstr_a
(
name
)
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
name
);
}
void
init_unix_codepage
(
void
)
{
char
charset_name
[
16
];
...
...
@@ -519,8 +551,7 @@ void init_unix_codepage(void)
int
res
=
_strnicmp
(
charset_names
[
pos
].
name
,
charset_name
,
-
1
);
if
(
!
res
)
{
if
(
charset_names
[
pos
].
cp
==
CP_UTF8
)
return
;
unix_table
=
wine_cp_get_table
(
charset_names
[
pos
].
cp
);
if
(
charset_names
[
pos
].
cp
!=
CP_UTF8
)
load_unix_cptable
(
charset_names
[
pos
].
cp
);
return
;
}
if
(
res
>
0
)
max
=
pos
-
1
;
...
...
@@ -547,6 +578,7 @@ static LCID unix_locale_to_lcid( const char *unix_name )
static
const
WCHAR
latnW
[]
=
{
'-'
,
'L'
,
'a'
,
't'
,
'n'
,
0
};
WCHAR
buffer
[
LOCALE_NAME_MAX_LENGTH
],
win_name
[
LOCALE_NAME_MAX_LENGTH
];
WCHAR
*
p
,
*
country
=
NULL
,
*
modifier
=
NULL
;
DWORD
len
;
LCID
lcid
;
if
(
!
unix_name
||
!
unix_name
[
0
]
||
!
strcmp
(
unix_name
,
"C"
))
...
...
@@ -555,7 +587,9 @@ static LCID unix_locale_to_lcid( const char *unix_name )
if
(
!
unix_name
||
!
unix_name
[
0
])
return
0
;
}
if
(
ntdll_umbstowcs
(
0
,
unix_name
,
strlen
(
unix_name
)
+
1
,
buffer
,
ARRAY_SIZE
(
buffer
)
)
<
0
)
return
0
;
len
=
ntdll_umbstowcs
(
unix_name
,
strlen
(
unix_name
),
buffer
,
ARRAY_SIZE
(
buffer
)
);
if
(
len
==
ARRAY_SIZE
(
buffer
))
return
0
;
buffer
[
len
]
=
0
;
if
(
!
(
p
=
strpbrkW
(
buffer
,
sepW
)))
{
...
...
@@ -702,16 +736,15 @@ void init_locale( HMODULE module )
/******************************************************************
* ntdll_umbstowcs
*/
int
ntdll_umbstowcs
(
DWORD
flags
,
const
char
*
src
,
int
srclen
,
WCHAR
*
dst
,
int
dstlen
)
DWORD
ntdll_umbstowcs
(
const
char
*
src
,
DWORD
srclen
,
WCHAR
*
dst
,
DWORD
dstlen
)
{
DWORD
reslen
;
NTSTATUS
status
;
if
(
unix_table
)
return
wine_cp_mbstowcs
(
unix_table
,
flags
,
src
,
srclen
,
dst
,
dstlen
);
if
(
unix_table
.
CodePage
)
RtlCustomCPToUnicodeN
(
&
unix_table
,
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
reslen
,
src
,
srclen
);
else
RtlUTF8ToUnicodeN
(
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
reslen
,
src
,
srclen
);
if
(
!
dstlen
)
dst
=
NULL
;
status
=
RtlUTF8ToUnicodeN
(
dst
,
dstlen
*
sizeof
(
WCHAR
),
&
reslen
,
src
,
srclen
);
if
(
status
&&
status
!=
STATUS_SOME_NOT_MAPPED
)
return
-
1
;
reslen
/=
sizeof
(
WCHAR
);
#ifdef __APPLE__
/* work around broken Mac OS X filesystem that enforces decomposed Unicode */
if
(
reslen
&&
dst
)
reslen
=
compose_string
(
dst
,
reslen
);
...
...
@@ -723,18 +756,50 @@ int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int d
/******************************************************************
* ntdll_wcstoumbs
*/
int
ntdll_wcstoumbs
(
DWORD
flags
,
const
WCHAR
*
src
,
int
srclen
,
char
*
dst
,
int
dstlen
,
const
char
*
defchar
,
int
*
used
)
int
ntdll_wcstoumbs
(
const
WCHAR
*
src
,
DWORD
srclen
,
char
*
dst
,
DWORD
dstlen
,
BOOL
strict
)
{
DWORD
reslen
;
NTSTATUS
status
;
DWORD
i
,
reslen
;
if
(
unix_table
)
return
wine_cp_wcstombs
(
unix_table
,
flags
,
src
,
srclen
,
dst
,
dstlen
,
defchar
,
used
);
if
(
used
)
*
used
=
0
;
/* all chars are valid for UTF-8 */
if
(
!
dstlen
)
dst
=
NULL
;
status
=
RtlUnicodeToUTF8N
(
dst
,
dstlen
,
&
reslen
,
src
,
srclen
*
sizeof
(
WCHAR
)
);
if
(
status
&&
status
!=
STATUS_SOME_NOT_MAPPED
)
return
-
1
;
if
(
!
unix_table
.
CodePage
)
RtlUnicodeToUTF8N
(
dst
,
dstlen
,
&
reslen
,
src
,
srclen
*
sizeof
(
WCHAR
)
);
else
if
(
!
strict
)
RtlUnicodeToCustomCPN
(
&
unix_table
,
dst
,
dstlen
,
&
reslen
,
src
,
srclen
*
sizeof
(
WCHAR
)
);
else
/* do it by hand to make sure every character roundtrips correctly */
{
if
(
unix_table
.
DBCSOffsets
)
{
const
unsigned
short
*
uni2cp
=
unix_table
.
WideCharTable
;
for
(
i
=
dstlen
;
srclen
&&
i
;
i
--
,
srclen
--
,
src
++
)
{
unsigned
short
ch
=
uni2cp
[
*
src
];
if
(
ch
>>
8
)
{
if
(
unix_table
.
DBCSOffsets
[
unix_table
.
DBCSOffsets
[
ch
>>
8
]
+
(
ch
&
0xff
)]
!=
*
src
)
return
-
1
;
if
(
i
==
1
)
break
;
/* do not output a partial char */
i
--
;
*
dst
++
=
ch
>>
8
;
}
else
{
if
(
unix_table
.
MultiByteTable
[
ch
]
!=
*
src
)
return
-
1
;
*
dst
++
=
(
char
)
ch
;
}
}
reslen
=
dstlen
-
i
;
}
else
{
const
unsigned
char
*
uni2cp
=
unix_table
.
WideCharTable
;
reslen
=
min
(
srclen
,
dstlen
);
for
(
i
=
0
;
i
<
reslen
;
i
++
)
{
unsigned
char
ch
=
uni2cp
[
src
[
i
]];
if
(
unix_table
.
MultiByteTable
[
ch
]
!=
src
[
i
])
return
-
1
;
dst
[
i
]
=
ch
;
}
}
}
return
reslen
;
}
...
...
@@ -744,8 +809,8 @@ int ntdll_wcstoumbs( DWORD flags, const WCHAR *src, int srclen, char *dst, int d
*/
UINT
CDECL
__wine_get_unix_codepage
(
void
)
{
if
(
!
unix_table
)
return
CP_UTF8
;
return
unix_table
->
info
.
codep
age
;
if
(
!
unix_table
.
CodePage
)
return
CP_UTF8
;
return
unix_table
.
CodeP
age
;
}
...
...
dlls/ntdll/ntdll_misc.h
View file @
9b01eda7
...
...
@@ -204,9 +204,8 @@ extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
/* locale */
extern
LCID
user_lcid
,
system_lcid
;
extern
int
ntdll_umbstowcs
(
DWORD
flags
,
const
char
*
src
,
int
srclen
,
WCHAR
*
dst
,
int
dstlen
)
DECLSPEC_HIDDEN
;
extern
int
ntdll_wcstoumbs
(
DWORD
flags
,
const
WCHAR
*
src
,
int
srclen
,
char
*
dst
,
int
dstlen
,
const
char
*
defchar
,
int
*
used
)
DECLSPEC_HIDDEN
;
extern
DWORD
ntdll_umbstowcs
(
const
char
*
src
,
DWORD
srclen
,
WCHAR
*
dst
,
DWORD
dstlen
)
DECLSPEC_HIDDEN
;
extern
int
ntdll_wcstoumbs
(
const
WCHAR
*
src
,
DWORD
srclen
,
char
*
dst
,
DWORD
dstlen
,
BOOL
strict
)
DECLSPEC_HIDDEN
;
extern
int
CDECL
NTDLL__vsnprintf
(
char
*
str
,
SIZE_T
len
,
const
char
*
format
,
__ms_va_list
args
)
DECLSPEC_HIDDEN
;
extern
int
CDECL
NTDLL__vsnwprintf
(
WCHAR
*
str
,
SIZE_T
len
,
const
WCHAR
*
format
,
__ms_va_list
args
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/path.c
View file @
9b01eda7
...
...
@@ -200,14 +200,14 @@ static int find_drive_rootW( LPCWSTR *ppath )
while
(
lenW
>
1
&&
IS_SEPARATOR
(
path
[
lenW
-
1
]))
lenW
--
;
/* convert path to Unix encoding */
lenA
=
ntdll_wcstoumbs
(
0
,
path
,
lenW
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
lenA
+
1
)))
return
-
1
;
lenA
=
ntdll_wcstoumbs
(
0
,
path
,
lenW
,
buffer
,
lenA
,
NULL
,
NULL
);
buffer
[
lenA
]
=
0
;
for
(
p
=
buffer
;
*
p
;
p
++
)
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
if
(
!
(
buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
lenW
*
3
+
1
)))
return
-
1
;
for
(;;)
{
lenA
=
ntdll_wcstoumbs
(
path
,
lenW
,
buffer
,
lenW
*
3
,
FALSE
);
buffer
[
lenA
]
=
0
;
for
(
p
=
buffer
;
*
p
;
p
++
)
if
(
*
p
==
'\\'
)
*
p
=
'/'
;
if
(
!
stat
(
buffer
,
&
st
)
&&
S_ISDIR
(
st
.
st_mode
))
{
/* Find the drive */
...
...
@@ -226,10 +226,6 @@ static int find_drive_rootW( LPCWSTR *ppath )
}
if
(
lenW
<=
1
)
break
;
/* reached root */
lenW
=
remove_last_componentW
(
path
,
lenW
);
/* we only need the new length, buffer already contains the converted string */
lenA
=
ntdll_wcstoumbs
(
0
,
path
,
lenW
,
NULL
,
0
,
NULL
,
NULL
);
buffer
[
lenA
]
=
0
;
}
RtlFreeHeap
(
GetProcessHeap
(),
0
,
buffer
);
return
-
1
;
...
...
@@ -1117,17 +1113,16 @@ NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRIN
{
if
(
status
==
STATUS_OBJECT_PATH_NOT_FOUND
)
{
lenW
=
ntdll_umbstowcs
(
0
,
path
,
lenA
,
NULL
,
0
);
nt
->
Buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
(
len
W
+
1
)
*
sizeof
(
WCHAR
)
+
sizeof
(
unix_prefixW
)
);
(
len
A
+
1
)
*
sizeof
(
WCHAR
)
+
sizeof
(
unix_prefixW
)
);
if
(
nt
->
Buffer
==
NULL
)
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
}
memcpy
(
nt
->
Buffer
,
unix_prefixW
,
sizeof
(
unix_prefixW
)
);
ntdll_umbstowcs
(
0
,
path
,
lenA
,
nt
->
Buffer
+
ARRAY_SIZE
(
unix_prefixW
),
len
W
);
lenW
+=
ARRAY_SIZE
(
unix_prefixW
);
lenW
=
ARRAY_SIZE
(
unix_prefix
W
);
lenW
+=
ntdll_umbstowcs
(
path
,
lenA
,
nt
->
Buffer
+
lenW
,
lenA
);
nt
->
Buffer
[
lenW
]
=
0
;
nt
->
Length
=
lenW
*
sizeof
(
WCHAR
);
nt
->
MaximumLength
=
nt
->
Length
+
sizeof
(
WCHAR
);
...
...
@@ -1138,9 +1133,8 @@ NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRIN
}
while
(
lenA
&&
path
[
0
]
==
'/'
)
{
lenA
--
;
path
++
;
}
lenW
=
ntdll_umbstowcs
(
0
,
path
,
lenA
,
NULL
,
0
);
if
(
!
(
nt
->
Buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
(
len
W
+
1
)
*
sizeof
(
WCHAR
)
+
sizeof
(
prefixW
)
)))
(
len
A
+
1
)
*
sizeof
(
WCHAR
)
+
sizeof
(
prefixW
)
)))
{
status
=
STATUS_NO_MEMORY
;
goto
done
;
...
...
@@ -1148,8 +1142,8 @@ NTSTATUS CDECL wine_unix_to_nt_file_name( const ANSI_STRING *name, UNICODE_STRIN
memcpy
(
nt
->
Buffer
,
prefixW
,
sizeof
(
prefixW
)
);
nt
->
Buffer
[
4
]
+=
drive
;
ntdll_umbstowcs
(
0
,
path
,
lenA
,
nt
->
Buffer
+
ARRAY_SIZE
(
prefixW
),
len
W
);
lenW
+=
ARRAY_SIZE
(
prefixW
);
lenW
=
ARRAY_SIZE
(
prefix
W
);
lenW
+=
ntdll_umbstowcs
(
path
,
lenA
,
nt
->
Buffer
+
lenW
,
lenA
);
nt
->
Buffer
[
lenW
]
=
0
;
nt
->
Length
=
lenW
*
sizeof
(
WCHAR
);
nt
->
MaximumLength
=
nt
->
Length
+
sizeof
(
WCHAR
);
...
...
dlls/ntdll/process.c
View file @
9b01eda7
...
...
@@ -814,9 +814,9 @@ static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved )
char
*
arg
,
*
s
,
*
d
,
*
cmdline
;
int
in_quotes
,
bcount
,
len
;
len
=
ntdll_wcstoumbs
(
0
,
cmdlineW
->
Buffer
,
cmdlineW
->
Length
/
sizeof
(
WCHAR
),
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
cmdline
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
+
1
)))
return
NULL
;
ntdll_wcstoumbs
(
0
,
cmdlineW
->
Buffer
,
cmdlineW
->
Length
/
sizeof
(
WCHAR
),
cmdline
,
len
,
NULL
,
NULL
);
len
=
cmdlineW
->
Length
/
sizeof
(
WCHAR
);
if
(
!
(
cmdline
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
*
3
+
1
)))
return
NULL
;
len
=
ntdll_wcstoumbs
(
cmdlineW
->
Buffer
,
len
,
cmdline
,
len
*
3
,
FALSE
);
cmdline
[
len
++
]
=
0
;
argc
=
reserved
+
1
;
...
...
@@ -1436,9 +1436,9 @@ static ULONG get_env_size( const RTL_USER_PROCESS_PARAMETERS *params, char **win
static
const
WCHAR
WINEDEBUG
[]
=
{
'W'
,
'I'
,
'N'
,
'E'
,
'D'
,
'E'
,
'B'
,
'U'
,
'G'
,
'='
,
0
};
if
(
!*
winedebug
&&
!
strncmpW
(
ptr
,
WINEDEBUG
,
ARRAY_SIZE
(
WINEDEBUG
)
-
1
))
{
DWORD
len
=
ntdll_wcstoumbs
(
0
,
ptr
,
strlenW
(
ptr
)
+
1
,
NULL
,
0
,
NULL
,
NULL
)
;
DWORD
len
=
strlenW
(
ptr
)
*
3
+
1
;
if
((
*
winedebug
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
)))
ntdll_wcstoumbs
(
0
,
ptr
,
strlenW
(
ptr
)
+
1
,
*
winedebug
,
len
,
NULL
,
NULL
);
ntdll_wcstoumbs
(
ptr
,
strlenW
(
ptr
)
+
1
,
*
winedebug
,
len
,
FALSE
);
}
ptr
+=
strlenW
(
ptr
)
+
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