Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-fonts
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
Aleksandr Isakov
wine-fonts
Commits
e5565a6d
Commit
e5565a6d
authored
Sep 23, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Sep 26, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Use helper function to return file io buffer.
parent
7fae5f4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
wcmdmain.c
programs/cmd/wcmdmain.c
+25
-22
No files found.
programs/cmd/wcmdmain.c
View file @
e5565a6d
...
@@ -102,6 +102,19 @@ static char *output_bufA = NULL;
...
@@ -102,6 +102,19 @@ static char *output_bufA = NULL;
#define MAX_WRITECONSOLE_SIZE 65535
#define MAX_WRITECONSOLE_SIZE 65535
static
BOOL
unicodePipes
=
FALSE
;
static
BOOL
unicodePipes
=
FALSE
;
/*
* Returns a buffer for reading from/writing to file
* Never freed
*/
static
char
*
get_file_buffer
(
void
)
{
if
(
!
output_bufA
)
{
output_bufA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_WRITECONSOLE_SIZE
);
if
(
!
output_bufA
)
WINE_FIXME
(
"Out of memory - could not allocate ansi 64K buffer
\n
"
);
}
return
output_bufA
;
}
/*******************************************************************
/*******************************************************************
* WCMD_output_asis_len - send output to current standard output
* WCMD_output_asis_len - send output to current standard output
...
@@ -126,23 +139,18 @@ static void WCMD_output_asis_len(const WCHAR *message, int len, HANDLE device) {
...
@@ -126,23 +139,18 @@ static void WCMD_output_asis_len(const WCHAR *message, int len, HANDLE device) {
if
(
!
res
)
{
if
(
!
res
)
{
BOOL
usedDefaultChar
=
FALSE
;
BOOL
usedDefaultChar
=
FALSE
;
DWORD
convertedChars
;
DWORD
convertedChars
;
char
*
buffer
;
if
(
!
unicodePipes
)
{
if
(
!
unicodePipes
)
{
/*
* Allocate buffer to use when writing to file. (Not freed, as one off)
if
(
!
(
buffer
=
get_file_buffer
()))
*/
return
;
if
(
!
output_bufA
)
output_bufA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_WRITECONSOLE_SIZE
);
if
(
!
output_bufA
)
{
WINE_FIXME
(
"Out of memory - could not allocate ansi 64K buffer
\n
"
);
return
;
}
/* Convert to OEM, then output */
/* Convert to OEM, then output */
convertedChars
=
WideCharToMultiByte
(
GetConsoleOutputCP
(),
0
,
message
,
convertedChars
=
WideCharToMultiByte
(
GetConsoleOutputCP
(),
0
,
message
,
len
,
output_bufA
,
MAX_WRITECONSOLE_SIZE
,
len
,
buffer
,
MAX_WRITECONSOLE_SIZE
,
"?"
,
&
usedDefaultChar
);
"?"
,
&
usedDefaultChar
);
WriteFile
(
device
,
output_bufA
,
convertedChars
,
WriteFile
(
device
,
buffer
,
convertedChars
,
&
nOut
,
FALSE
);
&
nOut
,
FALSE
);
}
else
{
}
else
{
WriteFile
(
device
,
message
,
len
*
sizeof
(
WCHAR
),
WriteFile
(
device
,
message
,
len
*
sizeof
(
WCHAR
),
...
@@ -223,21 +231,16 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars,
...
@@ -223,21 +231,16 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars,
if
(
!
res
)
{
if
(
!
res
)
{
DWORD
numRead
;
DWORD
numRead
;
/*
char
*
buffer
;
* Allocate buffer to use when reading from file. Not freed
*/
if
(
!
(
buffer
=
get_file_buffer
()))
if
(
!
output_bufA
)
output_bufA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
return
FALSE
;
MAX_WRITECONSOLE_SIZE
);
if
(
!
output_bufA
)
{
WINE_FIXME
(
"Out of memory - could not allocate ansi 64K buffer
\n
"
);
return
0
;
}
/* Read from file (assume OEM codepage) */
/* Read from file (assume OEM codepage) */
res
=
ReadFile
(
hIn
,
output_bufA
,
maxChars
,
&
numRead
,
unused
);
res
=
ReadFile
(
hIn
,
buffer
,
maxChars
,
&
numRead
,
unused
);
/* Convert from OEM */
/* Convert from OEM */
*
charsRead
=
MultiByteToWideChar
(
GetConsoleCP
(),
0
,
output_bufA
,
numRead
,
*
charsRead
=
MultiByteToWideChar
(
GetConsoleCP
(),
0
,
buffer
,
numRead
,
intoBuf
,
maxChars
);
intoBuf
,
maxChars
);
}
}
...
...
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