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
a8df9b14
Commit
a8df9b14
authored
Jan 29, 2013
by
Piotr Caban
Committed by
Alexandre Julliard
Jan 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use temporary buffers to speed up operations on stdout and stderr.
parent
2ee5323a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
file.c
dlls/msvcrt/file.c
+43
-0
No files found.
dlls/msvcrt/file.c
View file @
a8df9b14
...
...
@@ -595,6 +595,29 @@ static BOOL msvcrt_alloc_buffer(MSVCRT_FILE* file)
return
TRUE
;
}
/* INTERNAL: Allocate temporary buffer for stdout and stderr */
static
BOOL
add_std_buffer
(
MSVCRT_FILE
*
file
)
{
static
char
buffers
[
2
][
MSVCRT_BUFSIZ
];
if
((
file
->
_file
!=
MSVCRT_STDOUT_FILENO
&&
file
->
_file
!=
MSVCRT_STDERR_FILENO
)
||
!
MSVCRT__isatty
(
file
->
_file
)
||
file
->
_bufsiz
)
return
FALSE
;
file
->
_ptr
=
file
->
_base
=
buffers
[
file
->
_file
==
MSVCRT_STDOUT_FILENO
?
0
:
1
];
file
->
_bufsiz
=
file
->
_cnt
=
MSVCRT_BUFSIZ
;
return
TRUE
;
}
/* INTERNAL: Removes temporary buffer from stdout or stderr */
/* Only call this function when add_std_buffer returned TRUE */
static
void
remove_std_buffer
(
MSVCRT_FILE
*
file
)
{
msvcrt_flush_buffer
(
file
);
file
->
_ptr
=
file
->
_base
=
NULL
;
file
->
_bufsiz
=
file
->
_cnt
=
0
;
}
/* INTERNAL: Convert integer to base32 string (0-9a-v), 0 becomes "" */
static
int
msvcrt_int_to_base32
(
int
num
,
char
*
str
)
{
...
...
@@ -3911,6 +3934,7 @@ int CDECL MSVCRT_fputs(const char *s, MSVCRT_FILE* file)
int
CDECL
MSVCRT_fputws
(
const
MSVCRT_wchar_t
*
s
,
MSVCRT_FILE
*
file
)
{
MSVCRT_size_t
i
,
len
=
strlenW
(
s
);
BOOL
tmp_buf
;
int
ret
;
MSVCRT__lock_file
(
file
);
...
...
@@ -3919,13 +3943,17 @@ int CDECL MSVCRT_fputws(const MSVCRT_wchar_t *s, MSVCRT_FILE* file)
MSVCRT__unlock_file
(
file
);
return
ret
;
}
tmp_buf
=
add_std_buffer
(
file
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
MSVCRT_fputwc
(
s
[
i
],
file
)
==
MSVCRT_WEOF
)
{
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
MSVCRT_WEOF
;
}
}
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
0
;
}
...
...
@@ -4271,10 +4299,13 @@ static int puts_clbk_file_w(void *file, int len, const MSVCRT_wchar_t *str)
*/
int
CDECL
MSVCRT_vfprintf
(
MSVCRT_FILE
*
file
,
const
char
*
format
,
__ms_va_list
valist
)
{
BOOL
tmp_buf
;
int
ret
;
MSVCRT__lock_file
(
file
);
tmp_buf
=
add_std_buffer
(
file
);
ret
=
pf_printf_a
(
puts_clbk_file_a
,
file
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
&
valist
);
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
ret
;
...
...
@@ -4285,12 +4316,15 @@ int CDECL MSVCRT_vfprintf(MSVCRT_FILE* file, const char *format, __ms_va_list va
*/
int
CDECL
MSVCRT_vfprintf_s
(
MSVCRT_FILE
*
file
,
const
char
*
format
,
__ms_va_list
valist
)
{
BOOL
tmp_buf
;
int
ret
;
if
(
!
MSVCRT_CHECK_PMT
(
file
!=
NULL
))
return
-
1
;
MSVCRT__lock_file
(
file
);
tmp_buf
=
add_std_buffer
(
file
);
ret
=
pf_printf_a
(
puts_clbk_file_a
,
file
,
format
,
NULL
,
FALSE
,
TRUE
,
arg_clbk_valist
,
NULL
,
&
valist
);
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
ret
;
...
...
@@ -4301,10 +4335,13 @@ int CDECL MSVCRT_vfprintf_s(MSVCRT_FILE* file, const char *format, __ms_va_list
*/
int
CDECL
MSVCRT_vfwprintf
(
MSVCRT_FILE
*
file
,
const
MSVCRT_wchar_t
*
format
,
__ms_va_list
valist
)
{
BOOL
tmp_buf
;
int
ret
;
MSVCRT__lock_file
(
file
);
tmp_buf
=
add_std_buffer
(
file
);
ret
=
pf_printf_w
(
puts_clbk_file_w
,
file
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
&
valist
);
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
ret
;
...
...
@@ -4315,12 +4352,15 @@ int CDECL MSVCRT_vfwprintf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms
*/
int
CDECL
MSVCRT_vfwprintf_s
(
MSVCRT_FILE
*
file
,
const
MSVCRT_wchar_t
*
format
,
__ms_va_list
valist
)
{
BOOL
tmp_buf
;
int
ret
;
if
(
!
MSVCRT_CHECK_PMT
(
file
!=
NULL
))
return
-
1
;
MSVCRT__lock_file
(
file
);
tmp_buf
=
add_std_buffer
(
file
);
ret
=
pf_printf_w
(
puts_clbk_file_w
,
file
,
format
,
NULL
,
FALSE
,
TRUE
,
arg_clbk_valist
,
NULL
,
&
valist
);
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
ret
;
...
...
@@ -4332,12 +4372,15 @@ int CDECL MSVCRT_vfwprintf_s(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __
int
CDECL
MSVCRT__vfwprintf_l
(
MSVCRT_FILE
*
file
,
const
MSVCRT_wchar_t
*
format
,
MSVCRT__locale_t
locale
,
__ms_va_list
valist
)
{
BOOL
tmp_buf
;
int
ret
;
if
(
!
MSVCRT_CHECK_PMT
(
file
!=
NULL
))
return
-
1
;
MSVCRT__lock_file
(
file
);
tmp_buf
=
add_std_buffer
(
file
);
ret
=
pf_printf_w
(
puts_clbk_file_w
,
file
,
format
,
locale
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
&
valist
);
if
(
tmp_buf
)
remove_std_buffer
(
file
);
MSVCRT__unlock_file
(
file
);
return
ret
;
...
...
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