Skip to content

Commit

Permalink
Teach internal printf about 'z' (#78685)
Browse files Browse the repository at this point in the history
In a previous PR, an attempt was made to remove
most Windows specific format flags. However, the
internal printf version we are using doesn't know
about the 'z' flag. In order to transition to the correct
flags so we can remove our printf, we need to teach
our printf about modern flags.
  • Loading branch information
AaronRobinsonMSFT authored Nov 22, 2022
1 parent ed1ed67 commit 045d928
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/cruntime/printfcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ BOOL Internal_ExtractFormatA(CPalThread *pthrCurrent, LPCSTR *Fmt, LPSTR Out, LP
*Prefix = PFF_PREFIX_LONGLONG;
}
#endif
if ((*Fmt)[0] == 'I')
if ((*Fmt)[0] == 'I' || (*Fmt)[0] == 'z')
{
/* grab prefix of 'I64' for __int64 */
if ((*Fmt)[1] == '6' && (*Fmt)[2] == '4')
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/pal/src/cruntime/silent_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ BOOL Silent_ExtractFormatA(LPCSTR *Fmt, LPSTR Out, LPINT Flags, LPINT Width, LPI
*Fmt += 3;
*Prefix = PFF_PREFIX_LONGLONG;
}
/* grab a prefix of 'z' */
else if (**Fmt == 'z')
{
#ifdef HOST_64BIT
*Prefix = PFF_PREFIX_LONGLONG;
#endif
++(*Fmt);
}
/* grab a prefix of 'h' */
else if (**Fmt == 'h')
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/pal/src/safecrt/input.inl
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static int __check_float_string(size_t nFloatStrUsed,
break;

#if _INTEGRAL_MAX_BITS >= 64
case _T('z'):
case _T('I'):
if ( (*(format + 1) == _T('6')) &&
(*(format + 2) == _T('4')) )
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/pal/src/safecrt/output.inl
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,16 @@ static const unsigned char __lookuptable_s[] = {
/* 'u' */ 0x08,
/* 'v' */ 0x00,
/* 'w' */ 0x07,
/* 'x' */ 0x08
/* 'x' */ 0x08,
/* 'y' */ 0x00,
/* 'z' */ 0x57
};
//#endif /* defined (_UNICODE) || defined (CPRFLAG) */

#endif /* FORMAT_VALIDATIONS */

#define FIND_CHAR_CLASS(lookuptbl, c) \
((c) < _T(' ') || (c) > _T('x') ? \
((c) < _T(' ') || (c) > _T('z') ? \
CH_OTHER \
: \
(enum CHARTYPE)(lookuptbl[(c)-_T(' ')] & 0xF))
Expand Down Expand Up @@ -776,6 +778,7 @@ int __cdecl _output (
}
break;

case _T('z'):
case _T('I'):
/*
* In order to handle the I, I32, and I64 size modifiers, we
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/pal/src/safecrt/safecrt_output_l.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ const char __lookuptable[] = {
/* 'u' */ 0x08,
/* 'v' */ 0x00,
/* 'w' */ 0x07,
/* 'x' */ 0x08
/* 'x' */ 0x08,
/* 'y' */ 0x00,
/* 'z' */ 0x37
};

#endif /* defined (_UNICODE) || defined (CPRFLAG) */
Expand All @@ -322,7 +324,7 @@ const char __lookuptable[] = {
#endif /* FORMAT_VALIDATIONS */

#define FIND_CHAR_CLASS(lookuptbl, c) \
((c) < _T(' ') || (c) > _T('x') ? \
((c) < _T(' ') || (c) > _T('z') ? \
CH_OTHER \
: \
(enum CHARTYPE)(lookuptbl[(c)-_T(' ')] & 0xF))
Expand Down Expand Up @@ -696,6 +698,7 @@ int __cdecl _output (
}
break;

case _T('z'):
case _T('I'):
/*
* In order to handle the I, I32, and I64 size modifiers, we
Expand Down

0 comments on commit 045d928

Please sign in to comment.