summaryrefslogtreecommitdiff
path: root/src/pal/src/safecrt/output.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/src/safecrt/output.inl')
-rw-r--r--src/pal/src/safecrt/output.inl39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/pal/src/safecrt/output.inl b/src/pal/src/safecrt/output.inl
index ae0692efc5..5b86cf2c96 100644
--- a/src/pal/src/safecrt/output.inl
+++ b/src/pal/src/safecrt/output.inl
@@ -857,6 +857,12 @@ int __cdecl _output (
flags |= FL_LONG; /* 'l' => long int or wchar_t */
}
break;
+ case _T('L'):
+ if (*format == _T('p'))
+ {
+ flags |= FL_LONG;
+ }
+ break;
case _T('I'):
/*
@@ -956,7 +962,11 @@ int __cdecl _output (
#else /* _UNICODE */
if (flags & (FL_LONG|FL_WIDECHAR)) {
wchar = (wchar_t) get_int_arg(&argptr);
- no_output = 1;
+ textlen = snprintf(buffer.sz, BUFFERSIZE, "%lc", wchar);
+ if (textlen == 0)
+ {
+ no_output = 1;
+ }
} else {
/* format multibyte character */
/* this is an extension of ANSI */
@@ -1172,7 +1182,15 @@ int __cdecl _output (
precision = 2 * sizeof(void *); /* number of hex digits needed */
#if PTR_IS_INT64
- flags |= FL_I64; /* assume we're converting an int64 */
+ if (flags & (FL_LONG | FL_SHORT))
+ {
+ /* %lp, %Lp or %hp - these print 8 hex digits*/
+ precision = 2 * sizeof(int32_t);
+ }
+ else
+ {
+ flags |= FL_I64; /* assume we're converting an int64 */
+ }
#elif !PTR_IS_INT
flags |= FL_LONG; /* assume we're converting a long */
#endif /* !PTR_IS_INT */
@@ -1371,7 +1389,22 @@ int __cdecl _output (
/* write text */
#ifndef _UNICODE
if (bufferiswide && (textlen > 0)) {
- charsout = -1;
+ const WCHAR *p;
+ int mbCharCount;
+ int count;
+ char mbStr[5];
+
+ p = text.wz;
+ count = textlen;
+ while (count-- > 0) {
+ mbCharCount = snprintf(mbStr, sizeof(mbStr), "%lc", *p);
+ if (mbCharCount == 0) {
+ charsout = -1;
+ break;
+ }
+ WRITE_STRING(mbStr, mbCharCount, &charsout);
+ p++;
+ }
} else {
WRITE_STRING(text.sz, textlen, &charsout);
}