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
bfc2f5f2
Commit
bfc2f5f2
authored
Apr 20, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Use callback based printf in sprintf functions family.
parent
b9e456aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
52 deletions
+70
-52
printf.h
dlls/msvcrt/printf.h
+24
-0
wcs.c
dlls/msvcrt/wcs.c
+46
-52
No files found.
dlls/msvcrt/printf.h
View file @
bfc2f5f2
...
...
@@ -35,6 +35,30 @@ typedef struct FUNC_NAME(pf_flags_t)
APICHAR
Format
;
}
FUNC_NAME
(
pf_flags
);
struct
FUNC_NAME
(
_str_ctx
)
{
MSVCRT_size_t
len
;
APICHAR
*
buf
;
};
static
int
FUNC_NAME
(
puts_clbk_str
)(
void
*
ctx
,
int
len
,
const
APICHAR
*
str
)
{
struct
FUNC_NAME
(
_str_ctx
)
*
out
=
ctx
;
if
(
!
out
->
buf
)
return
len
;
if
(
out
->
len
<
len
)
{
memcpy
(
out
->
buf
,
str
,
out
->
len
);
out
->
buf
+=
out
->
len
;
out
->
len
=
0
;
return
-
1
;
}
memcpy
(
out
->
buf
,
str
,
len
*
sizeof
(
APICHAR
));
out
->
buf
+=
len
;
return
len
;
}
static
inline
const
APICHAR
*
FUNC_NAME
(
pf_parse_int
)(
const
APICHAR
*
fmt
,
int
*
val
)
{
*
val
=
0
;
...
...
dlls/msvcrt/wcs.c
View file @
bfc2f5f2
...
...
@@ -1114,40 +1114,19 @@ printf_arg arg_clbk_valist(void *ctx, int arg_pos, int type, __ms_va_list *valis
}
/*********************************************************************
* vsnprintf_internal (INTERNAL)
*/
static
inline
int
vsnprintf_internal
(
char
*
str
,
MSVCRT_size_t
len
,
const
char
*
format
,
MSVCRT__locale_t
locale
,
BOOL
valid
,
__ms_va_list
valist
)
{
DWORD
sz
;
LPWSTR
formatW
=
NULL
;
pf_output
out
;
int
r
;
out
.
unicode
=
FALSE
;
out
.
buf
.
A
=
str
;
out
.
grow
.
A
=
NULL
;
out
.
used
=
0
;
out
.
len
=
len
;
sz
=
MultiByteToWideChar
(
CP_ACP
,
0
,
format
,
-
1
,
NULL
,
0
);
formatW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sz
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
format
,
-
1
,
formatW
,
sz
);
r
=
pf_vsnprintf
(
&
out
,
formatW
,
locale
,
valid
,
valist
);
HeapFree
(
GetProcessHeap
(),
0
,
formatW
);
return
r
;
}
/*********************************************************************
* _vsnprintf (MSVCRT.@)
*/
int
CDECL
MSVCRT_vsnprintf
(
char
*
str
,
MSVCRT_size_t
len
,
const
char
*
format
,
__ms_va_list
valist
)
{
return
vsnprintf_internal
(
str
,
len
,
format
,
NULL
,
FALSE
,
valist
);
static
const
char
nullbyte
=
'\0'
;
struct
_str_ctx_a
ctx
=
{
len
,
str
};
int
ret
;
ret
=
pf_printf_a
(
puts_clbk_str_a
,
&
ctx
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_a
(
&
ctx
,
1
,
&
nullbyte
);
return
ret
;
}
/*********************************************************************
...
...
@@ -1156,7 +1135,14 @@ int CDECL MSVCRT_vsnprintf( char *str, MSVCRT_size_t len,
int
CDECL
MSVCRT_vsnprintf_l
(
char
*
str
,
MSVCRT_size_t
len
,
const
char
*
format
,
MSVCRT__locale_t
locale
,
__ms_va_list
valist
)
{
return
vsnprintf_internal
(
str
,
len
,
format
,
locale
,
FALSE
,
valist
);
static
const
char
nullbyte
=
'\0'
;
struct
_str_ctx_a
ctx
=
{
len
,
str
};
int
ret
;
ret
=
pf_printf_a
(
puts_clbk_str_a
,
&
ctx
,
format
,
locale
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_a
(
&
ctx
,
1
,
&
nullbyte
);
return
ret
;
}
/*********************************************************************
...
...
@@ -1166,6 +1152,8 @@ int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
MSVCRT_size_t
count
,
const
char
*
format
,
MSVCRT__locale_t
locale
,
__ms_va_list
valist
)
{
static
const
char
nullbyte
=
'\0'
;
struct
_str_ctx_a
ctx
;
int
len
,
ret
;
if
(
sizeOfBuffer
<
count
+
1
||
count
==-
1
)
...
...
@@ -1173,7 +1161,11 @@ int CDECL MSVCRT_vsnprintf_s_l( char *str, MSVCRT_size_t sizeOfBuffer,
else
len
=
count
+
1
;
ret
=
vsnprintf_internal
(
str
,
len
,
format
,
locale
,
TRUE
,
valist
);
ctx
.
len
=
len
;
ctx
.
buf
=
str
;
ret
=
pf_printf_a
(
puts_clbk_str_a
,
&
ctx
,
format
,
locale
,
FALSE
,
TRUE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_a
(
&
ctx
,
1
,
&
nullbyte
);
if
(
ret
<
0
||
ret
==
len
)
{
if
(
count
!=
MSVCRT__TRUNCATE
&&
count
>
sizeOfBuffer
)
{
...
...
@@ -1263,30 +1255,19 @@ int CDECL MSVCRT__scprintf(const char *format, ...)
}
/*********************************************************************
* vsnwprintf_internal (INTERNAL)
*/
static
inline
int
vsnwprintf_internal
(
MSVCRT_wchar_t
*
str
,
MSVCRT_size_t
len
,
const
MSVCRT_wchar_t
*
format
,
MSVCRT__locale_t
locale
,
BOOL
valid
,
__ms_va_list
valist
)
{
pf_output
out
;
out
.
unicode
=
TRUE
;
out
.
buf
.
W
=
str
;
out
.
grow
.
W
=
NULL
;
out
.
used
=
0
;
out
.
len
=
len
;
return
pf_vsnprintf
(
&
out
,
format
,
locale
,
valid
,
valist
);
}
/*********************************************************************
* _vsnwprintf (MSVCRT.@)
*/
int
CDECL
MSVCRT_vsnwprintf
(
MSVCRT_wchar_t
*
str
,
MSVCRT_size_t
len
,
const
MSVCRT_wchar_t
*
format
,
__ms_va_list
valist
)
{
return
vsnwprintf_internal
(
str
,
len
,
format
,
NULL
,
FALSE
,
valist
);
static
const
MSVCRT_wchar_t
nullbyte
=
'\0'
;
struct
_str_ctx_w
ctx
=
{
len
,
str
};
int
ret
;
ret
=
pf_printf_w
(
puts_clbk_str_w
,
&
ctx
,
format
,
NULL
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_w
(
&
ctx
,
1
,
&
nullbyte
);
return
ret
;
}
/*********************************************************************
...
...
@@ -1296,7 +1277,14 @@ int CDECL MSVCRT_vsnwprintf_l(MSVCRT_wchar_t *str, MSVCRT_size_t len,
const
MSVCRT_wchar_t
*
format
,
MSVCRT__locale_t
locale
,
__ms_va_list
valist
)
{
return
vsnwprintf_internal
(
str
,
len
,
format
,
locale
,
FALSE
,
valist
);
static
const
MSVCRT_wchar_t
nullbyte
=
'\0'
;
struct
_str_ctx_w
ctx
=
{
len
,
str
};
int
ret
;
ret
=
pf_printf_w
(
puts_clbk_str_w
,
&
ctx
,
format
,
locale
,
FALSE
,
FALSE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_w
(
&
ctx
,
1
,
&
nullbyte
);
return
ret
;
}
/*********************************************************************
...
...
@@ -1306,13 +1294,19 @@ int CDECL MSVCRT_vsnwprintf_s_l( MSVCRT_wchar_t *str, MSVCRT_size_t sizeOfBuffer
MSVCRT_size_t
count
,
const
MSVCRT_wchar_t
*
format
,
MSVCRT__locale_t
locale
,
__ms_va_list
valist
)
{
static
const
MSVCRT_wchar_t
nullbyte
=
'\0'
;
struct
_str_ctx_w
ctx
;
int
len
,
ret
;
len
=
sizeOfBuffer
;
if
(
count
!=-
1
&&
len
>
count
+
1
)
len
=
count
+
1
;
ret
=
vsnwprintf_internal
(
str
,
len
,
format
,
locale
,
TRUE
,
valist
);
ctx
.
len
=
len
;
ctx
.
buf
=
str
;
ret
=
pf_printf_w
(
puts_clbk_str_w
,
&
ctx
,
format
,
locale
,
FALSE
,
TRUE
,
arg_clbk_valist
,
NULL
,
valist
);
puts_clbk_str_w
(
&
ctx
,
1
,
&
nullbyte
);
if
(
ret
<
0
||
ret
==
len
)
{
if
(
count
!=
MSVCRT__TRUNCATE
&&
count
>
sizeOfBuffer
)
{
...
...
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